A server side include is a file that is included within the current document on the server. This can save the developer a considerable amout of time. If all of the pages on your site have a similar header, you can include a single file containing the header into your pages. When the header needs updating, you only update the one page, which is included in all of the pages that use the header. As many include files may be used as required.
In PHP, server side includes are achieved using the require statement. The following example includes a banner that contains a logo and set of links for the pages.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Server Side Include</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<?php require("banner.html"); ?>
<p>
This page contains a banner that may be incuded in any
of the PHP files used on this site.
</p>
</body>
</html>
Comments