Home > Tutorials > php > Including Files
Including files with php is very easy to do. This tutorial shows you how.
The main reasons why you might use php includes/require one of these reasons is to include the footer in to every page but only have one footer.
Let me explain you create a new file in can be a .html or .php extension either will work I always choose .php extension as I usually has some php running even in the footer.
In your new file save it as footer.php and in the file only have what you want in the footer do not put in the doc type or
<?php
<div id="footer">Copyright © your name <?php echo date('Y');?> </div><!-- close footer -->
?>
<?php include ('footer.php'); ?> or if your included file is in another folder:
<?php include ('folder-name/footer.php'); ?>
<?php require ('footer.php'); ?> or if your required file is in another folder:
<?php require ('folder-name/footer.php'); ?>
Posted on Saturday, February 23rd, 2008 viewed 135 times, 0 Comments
No comments yet