Welcome to the last installment of the series “Overloading classes in PHP.” Comprised of three tutorials, this series shows you how to overload your classes whether you’re using PHP 4 or PHP 5, and explains in detail the implementation of the “__set()”, “__get()” and “__call()” methods, in order to overload property accesses and method calls respectively.
As you learned in the previous articles, after a class has been overloaded by the “overload()” function that comes with PHP 4, it’s possible to run custom code automatically by calling the set of methods that I mentioned right at the beginning of this tutorial. Whether you’re overloading a property access, in order to call the “__set()” and “__get()” methods, or using an overloaded method call, which obviously triggers the “__call()” method, PHP provides you with the ability to invoke these methods automatically and run specific code without having to write explicit method calls inside an application.
Also, it should be noticed that overloading classes in PHP 4 isn’t as powerful as in other object-oriented languages like C++ or Python, but as I hopefully demonstrated by the numerous hands-on examples I showed previously, PHP offers a fairly comprehensive set of methods for overloading classes in a simple way.
Now that you learned the pros and cons of overloading classes in PHP 4, it’s time to move on and continue exploring the subject, since there are still a few additional topics that need to be covered. So, what’s comes next now? All right, in this last part of the series, I’ll be explaining how to overload classes specifically in PHP 5, which offers native support for overloading class members and methods, without having to explicitly call the PHP built-in “overload()” function.
Are you ready to learn how to overload your PHP 5 classes? Right, let’s begin.