Well of Stars

PHP Includes

You may find it useful to convert your site to php, even if you don't plan to skin it. Using the method of php includes described below can make updating your layout much simpler - you need only change your header or footer.php file, instead of having to edit every page of your site.

The Include Code

For simple php includes (not skins), you need to add the following bit of code at the top of all your content pages (index.php, updates.php... everything except header.php and footer.php):

<?php
@ require_once("header.php");
?>

N.B I use require_once as recommended in an article at A List Apart. However, require_once() only works in PHP version 4 or later, so if you have an older version of PHP installed on your server, you would need to use include() or require().

At the end of each content page, add the following:

<?php
@ require_once("footer.php");
?>

Upload all files, including header.php and footer.php, into your main site directory. If everything is correctly in place, you should have your php site :)

On to Skinning
Back to contents