PHP Includes for Non-Developers
2008
Jul 31st
published in
Uncategorized
I usually will not write tutorials as there are many great ones available on any given topic; but this one I have not often seen, and would have loved to have known about it along time ago.
Any HTML/CSS web designer who doesn’t know PHP can certainly make good use of this PHP include statement. PHP includes are very useful for making global changes on smaller HTML/CSS websites, just as CSS is a tool to easily make global changes to styles and layouts.

Here is an example scenario: A client has a 30 page HTML/CSS website that they need built and do not want to mess with a content management system. This means that every time you need to make a change while building the site in a area such as the header, navigation, sidebar or footer you will need to update 30 pages; or if the client wants an item updated after the side is done you may need to update 30 pages.
Not fun.
PHP includes are useful with areas that are consistent through the entire website such as a header, navigation, sidebar, footer or any other area that is repeated.
The PHP include is put in place of, lets say, all of the code that makes up the navigation. This code is then placed into a single php file which the php include will reference. Then every time you need to update the navigation, you will simply need to make the changes in that single php file, and the site will update globally!
Put generically, what happens is the line of code that is the PHP include replaces the area in the HTML page that you want to be able to update. Here is the magic line of code:
This will make more sense with an example. Let say we just finished coding the HTML/CSS index page template that we are going to use for every page of a site.
HTML/CSS index template code:
Here is the header.
Here is the body.
comments
6