PHP example using server-side includes

This page is constructed from 4 seperate PHP files, the parent index.php file and 3 includes, one for the header, one for the navigation and one for the footer.

The include files are in a subfolder called "includes" and they are named, and

In each case, the include statement looks like this:

<?php include('includes/'); ?>

The include statement above uses a relative path to the included file.

If the include folder was in the document root, a portable, absolute URL could be used as follows:

<?php include($_SERVER['DOCUMENT_ROOT'].'/includes/'); ?>


To keep everything up to date, the footer contains a small script that prints the current year:

<?php echo date("Y"); ?>

The upper-case Y tells the date function to return only the 4-digit year number, which is printed by the echo function.