Specifications
}
function DisplayFooter()
{
?>
<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 information page</a></p>
</td>
</tr>
</table>
<?
}
}
?>
When reading it, note that DisplayStyles(), DisplayHeader(), and DisplayFooter() need to
display a large block of static HTML, with no PHP processing. Therefore, we have simply
used an end PHP tag (?>), typed our HTML, and then re-entered PHP with an open PHP tag
(<?) while inside the functions.
Two other operations are defined in this class. The operation DisplayButton() outputs a sin-
gle menu button. If the button is to point to the page we are on, we are displaying an inactive
button instead, which looks slightly different, and does not link anywhere. This keeps the page
layout consistent and provides visitors with a visual location.
The operation IsURLCurrentPage() determines if the URL for a button points to the current
page. Lots of techniques can be used to discover this. We have used the string function
strpos() to see if the URL given is contained in one of the server set variables. The state-
ment strpos( $GLOBALS[“SCRIPT_NAME”], $url ) will either return a number if the string
in $url is inside the global variable SCRIPT_NAME, or false if it is not.
To use this page class, we need to include page.inc in a script and call Display().
The code in Listing 6.2 will create TLA Consulting’s home page and give output very similar
to that we previously generated in Figure 5.2.
The code in Listing 6.2 does the following:
1. Uses require to include the contents of page.inc, which contains the definition of the
class Page.
Object-Oriented PHP
C
HAPTER 6
6
OBJECT-ORIENTED
PHP
165
LISTING 6.1 Continued
08 7842 CH06 3/6/01 3:34 PM Page 165