Specifications
LISTING 5.4 footer.inc—The Reusable Footer for All TLA Web Pages
<!-- page footer -->
<table width = “100%” bgcolor = black cellpadding = 12 border = 0>
<tr>
<td>
<p class=foot>© TLA Consulting Pty Ltd.</p>
<p class=foot>Please see our
<a href =”legal.php3”>legal information page</a></p>
</td>
</tr>
</table>
</body>
</html>
This approach gives you a consistent looking Web site very easily, and you can make a new
page in the same style by typing something like:
<? require(“header.inc”); ?>
Here is the content for this page
<? require(“footer.inc”); ?>
Most importantly, even after we have created many pages using this header and footer, it is
easy to change the header and footer files. Whether you are making a minor text change, or
completely redesigning the look of the site, you only need to make the change once. We do not
need to separately alter every page in the site because each page is loading in the header and
footer files.
The example shown here only uses plain HTML in the body, header and footer. This need not
be the case. Within these files, we could use PHP statements to dynamically generate parts of
the page.
Using auto_prepend_file and auto_append_file
If we want to use require() to add our header and footer to every page, there is another way
we can do it. Two of the configuration options in the php.ini file are auto_prepend_file and
auto_append_file. By setting these to our header and footer files, we ensure that they will be
loaded before and after every page.
For Windows, the settings will resemble the following:
auto_prepend_file = “c:/inetpub/include/header.inc”
auto_append_file = “c:/inetpub/include/footer.inc”
For UNIX, they will resemble the following:
auto_prepend_file = “/home/username/include/header.inc”
auto_append_file = “/home/username/include/footer.inc”
Using PHP
P
ART I
126
07 7842 CH05 3/6/01 3:35 PM Page 126