|
The include function is definitely one of the most useful PHP functions ever! Especially if your web site has more than a few pages. I don't know what I'd do without it, especially since I don't use a CMS.
The include function allows you to change things simultaenously on multiple pages. For example, if your layout includes a sidebar, you don't want to have to go through every single page of your site to change the sidebar every time you want to modify something in it. You can put the entire sidebar contents in a different file and use the include function. The include function looks like <?php include("file.php"); ?> and it really doesn't matter whether you include HTML or PHP files.
The best way to demonstrate is through an example. Each of my individual pages on this site actually looks something like this:
Page content here. <?php include("footer.php"); ?> |