Specifications

Outside the class definition, we create an instance of our ServicesPage class, set the values for
which we want non-default values and call Display().
As shown in Figure 6.2, we have a new variant of our standard page. The only new code we
needed to write was for the parts that were different.
Using PHP
P
ART I
168
FIGURE 6.2
The services page is created using inheritance to reuse most of our standard page.
Creating pages via PHP classes has obvious advantages. With a class to do most of the work
for us, we needed to do less work to create a new page. We can update all our pages at once by
simply updating the class. Using inheritance, we can derive different versions of the class from
our original without compromising the advantages.
As with most things in life, these advantages do not come without cost.
Creating pages from a script requires more computer processor effort than simply loading a
static HTML page from disk and sending it to a browser. On a busy site this will be important,
and you should make an effort to either use static HTML pages or cache the output of your
scripts where possible to reduce the load on the server.
Next
The next section deals with MySQL. Well talk about how to create and populate a MySQL
database, and then link what weve learned to PHP so that you can access your database from
the Web.
08 7842 CH06 3/6/01 3:34 PM Page 168