PHP Server Side Includes

One of php‘s most practical solutions is a server side include.

Consider the navigation at the top of every page on this website. At time of writing there is 7 unique pages on, excluding this blog. If I were to add a new page to my site, would I not have to update each and every page to show the new link?

What a horrible sounding job — what if I had to make 2 or 3 changes to each and every one of those pages? In the context of 7 pages this might take say 10-15 minutes to open, change, save and upload 7 files. But what about if I have 20, 50, or 1000 different pages? This could take a day, if not a week!

What a horrible way to spend a week… and yet i’m sure someone, somewhere, in a deep, dark dungeon has slaved away at this menial task for hours on end.

All bow to King server side include!

A Server Side Include is a fairly ordinary file that is created for a website. It can contain any kind of web friendly content, but the most common usage is to display the same things over and over on different pages. So utilising this fantastic technology I have 1 file that contains my main navigation. If I want to rename, add, delete… or make any change under the sun, a server side include is my friend. I change the file once, and like magic every instance of the file is now reflecting the changes. Cool huh?

For any web people who have just read this post, don’t worry, I won’t leave you in the dark about how to do it – my favourite method is php.


For Dreamweaver users, use brackets – the above will leave a lovely/nasty little php symbol instead of the visual contents of the file. Try this to have the file contents display perfectly in your design view:


Remember that the path can be relative or absolute. If you work with folders for example, you may need something like this if the current file is located in its own folder.


You can also use the absolute path, which is commonly required in configuration files of popular applications. You will need to know your absolute server path, which frequently looks something like this:

 include ('home/username/public_html/includes/navigation.php'); 

Need help setting up server side includes or developing your site in some way? Read about Thomas Multimedia’s web design services¬†

3 Replies to “PHP Server Side Includes”

Leave a Reply

Your email address will not be published. Required fields are marked *