January 10th, 2007PHP require() & include()
Hi readers. one of the most useful functions that PHP can perform are the require and include functions. These two functions are very similar in the action that they perform. They can call a page from anywhere in your directory (or another one) to a page. The most comment use for this is where headers and footers are involved.
Say, for instance, you have a 10 page web site and you need to edit the links of the page which happen to be text links and appear at the top of each page. With PHP instead of having to edit each page individually you can edit just one - which in the long run will save you a lot of time when editing your pages.
To achieve this, you need to split your page into three sections: a header, the main page and the footer.
Copy the header of the page into a new file and name this new file “header.php” and do the same for the footer, except name this file “footer.php”. Then delete the “header” and “footer” from each of the other pages. Where the header of each file was enter this code:
PHP Code:
require(”header.php”);
?>
Do this for the footer of each page as well, except enter the code below:
PHP Code:
require(”footer.php”);
?>
If you now upload all the pages, including the “header.php” and “footer.php” files and now, whenever you need to edit the header or footer of each page of each file, just open up the “header.php” and “footer.php” files and edit them - simple!
Thanks.

January 15th, 2007 at 9:47 pm
This can be very handy for some people; with include() and require() you can also build very nice web applications! I can recommend everyone using it
Thanks! 
January 15th, 2007 at 10:05 pm
Nice and basic, we all have to start somewhere.
Personally i would have focused more on the difference between the two functions are how code is evaluated/included but i appreciate this is the basics
January 19th, 2007 at 4:31 am
Cool tutorial, definately useful!
January 20th, 2007 at 2:47 pm
OK tut, if I ever start php`ing, i’ll definetly use it.