Server Side Includes (SSI)
If your web host says it supports server side includes (SSI), then it means that you can use HTML tags to display dynamic content on a web page. SSI allows you to use one include file to display the same piece of code on numerous pages thus cutting down time when it comes to changing and editing the code. You simply include the SSI file inside the HTML/PHP page and the code from the server side include will show on the page. If you then have to change the code, the changes only need to be made in the one include file but will apply to all pages that the include file is displayed on.
Server side includes when listed at a web host generally refer to Perl based HTML commands that tell a server to generate output from the include files. There are however other ways to take advantage of the benefits of SSI without worrying whether or not your host supports it. Because include are a basic part of PHP, every Linux web host supports the use of includes.
Include files are useful for headers, footers, advertisements and any other common website elements that are displayed on all or many pages. The most widely used application for include files however is for website navigation menus.
If a new page is added to a static website, updating the menu on each and every page is time consuming and prone to errors. If however the navigation menu is located inside an include file, this is the only file that must be changed. These changes will then be reflected on every web page that calls up the include file.
How to Create a PHP Include File
This short tutorial will explain how to create and use a PHP include file.
- Copy your header, footer or navigation menu and paste it into a brand new text document.
- Save the text document as include.php (you can however name it whatever you wish).
- Where your code was in the original web page, replace it with <?php include("include.php"); ?>
- Upload all files to your web host and you will now see the website looks exactly the same, but you have just saved yourself many hours of editing time should you wish to update hundreds of web pages; it can now be done in one file.
You can have as many includes called on a web page as you wish, just make sure they all have a unique file name. PHP includes require the web page to have a .php extension.
Back


