Server Side Includes Tutorial

Made by: Nick

Server side includes (SSI's) are files which have some commonly used code inside them which you can then attach to any page of your website which uses them (for example the page layout code should be the same on each page, so we include that using server side includes). They help you save a lot of time if your site is large and also help minimize any mistakes in the code.

The Code

First you have to create a file with the commonly used code inside it and save it as "filename.php". We save it as a PHP file incase we have any sensitive data inside it (e.g. MYSQL database information and passwords).

All that we do then is add this code to wherever you want the common code to appear in your main PHP file:

<?php include("relative_path_to_document") ?>

Note that SSI's do not work in .html, .htm or any other static file types, they only work in server side languages such as PHP and ASP (although I havn't given you the code for the ASP include as this is a PHP tutorial).

Feed the Dragon MySpace Tutorials