HomePHP Abstract Classes in PHP: Working with PHP 5
Abstract Classes in PHP: Working with PHP 5
Here we are again. This is the tutorial you’ve been waiting for! Welcome to the last part of the series “Abstract classes in PHP.” If you’ve already read the previous articles, then you’ll know that this series introduces the basics of abstract classes in PHP 4/PHP 5, and illustrates their use and implementation in concrete situations.
Before I leap forward, it’s worth a brief look back to remind you of what you learned during the previous installment of this series, so it’ll be much easier to continue with the topics that will be discussed in this final tutorial. As you’ll recall, in the second part I demonstrated how to create a well-defined hierarchy of data processing PHP 4 classes, with the base class being abstract. This originally provided a set of undefined, highly generic methods for converting data to different formats.
In consonance with the concepts deployed before, I derived two specific subclasses from the base class. These classes were responsible for processing file data, along with MySQL result sets. To achieve these tasks, each child class provided a concrete implementation for each generic method declared within the corresponding parent class. This condition demonstrated how to use a PHP 4 abstract class as the starting point from which to derive as many subclasses as needed, in order to perform concrete operations within a given PHP application.
As you know, the whole idea of defining an abstract class is to allow you to define generic characteristics of a given object (including properties and methods), and then implement a concrete functionality by using the methods of the respective subclasses. So now it’s clear and fresh in your mind what abstract classes are and how to use them during the development cycle of a Web application.
That said, in this last part of the series, I’ll explain the key points of abstract classes in PHP 5, and additionally provide you with some hands-on examples. This should give you a clear idea of how to utilize them within the powerful Object Model implemented in the latest version of PHP.
Assuming that you’re interested in learning more about PHP 5 abstract classes, it’s time to move forward and find out how to use them. Let’s get going!