Specifications

We can also set attributes to store the pages title. We will probably want to change this to
clearly show what particular page our visitor is looking at. Rather than have blank titles, we
will provide a default title with the following declaration:
var $title = “TLA Consulting Pty Ltd”;
Most commercial Web pages include metatags to help search engines index them. In order to
be useful, metatags should probably change from page to page. Again, we will provide a
default value:
var $keywords = “TLA Consulting, Three Letter Abbreviation,
some of my best friends are search engines”;
The navigation buttons shown on the original page in Figure 5.2 (see the previous chapter)
should probably be kept the same from page to page to avoid confusing people, but in order to
change them easily, we will make them an attribute too. Because there might be a variable
number of buttons, we will use an array, and store both the text for the button and the URL it
should point to.
var $buttons = array( “Home” => “home.php”,
“Contact” => “contact.php”,
“Services” => “services.php”,
“site Map” => “map.php”
);
In order to provide some functionality, our class will also need operations. We can start by pro-
viding accessor functions to set and get the values of the attributes we defined. These all take a
form like this:
function SetContent($newcontent)
{
$this->content = $newcontent;
}
Because it is unlikely that we will be requesting any of these values from outside the class, we
have elected not to provide a matching collection of
GET functions.
The main purpose of this class is to display a page of HTML, so we will need a function. We
have called ours Display(), and it is as follows:
function Display()
{
echo “<html>\n<head>\n”;
$this -> DisplayTitle();
$this -> DisplayKeywords();
$this -> DisplayStyles();
echo “</head>\n<body>\n”;
Using PHP
P
ART I
160
08 7842 CH06 3/6/01 3:34 PM Page 160