HomePHP Completing a Web Site Template using Inheritance in PHP 5
Completing a Web Site Template using Inheritance in PHP 5
If you're a PHP developer who develops object-oriented applications on a frequent basis, then you'll know that inheritance can be an extremely useful concept that might help in reusing code when it comes to creating a hierarchy of classes. This article, and yesterday's, take advantage of this powerful concept and show you how to use some straightforward classes to build a complete web site that presents a consistent look across its pages.
Now that I have introduced the topics that will be covered in these tutorials, let me briefly recapitulate contents of the first part of the series, in case you didn't read that article.
As I stated at the beginning, the remarkable functionality provided by inheritance can be used in all sorts of clever ways, including the development of database abstraction layers, form generating and validating systems, error loggers, and so forth. However, in this situation I decided to demonstrate how a well-defined set of hierarchical classes can be utilized with the purpose of creating the different sections that comprise a simple web site.
Even though the project itself may look rather primitive at first sight, it's useful for illustrating yet another approach to building web sites that expose a consistent visual appearance across their pages. And speaking specifically of creating a web site by using the concept of inheritance, you'll possibly remember that over the course of the preceding article, I showed you how to develop the classic "Home" and "About us" pages of a fictional web site utilizing a couple of inherited classes, whose respective signatures were indeed very easy to code.
Thus, taking into account the same development methodology I described above, in this final installment of the series I'm going to complete the creation of the sample website by developing a pair of additional web pages, which will come in useful for building the typical "Products" and "Contact" sections of the web site in question.
The experience will be instructive, so let's discover the real power behind using inheritance with PHP 5. Let's get started!