HomePHP Retrieving Information on Several Objects with Destructors in PHP 5
Retrieving Information on Several Objects with Destructors in PHP 5
Welcome to the fourth part of the series “Understanding Destructors in PHP 5.” Made up of five comprehensive tutorials, this series brings to you the foundations of how to declare and implement destructors in PHP 5-driven classes. And it tackles this process from a practical point of view, since you’ll be able to learn these methods by using copious examples.
As you know, a destructor is simply a magic method supported by the highly-improved object model of PHP 5. When implemented by a determined object, it will be automatically called by the interpreter prior to removing the object in question from the web server’s memory.
Obviously, the intrinsic nature of destructors make them very useful for performing certain tasks, right before a specific application finishes its execution and all of its objects are deleted. Therefore, if you wish to learn how to use them as part of your own PHP 5 classes, this group of educational articles might be the guide that you’ve been searching for.
Now that you know what this article series is about, it’s time to review the topics that I discussed in the last article concerning the adequate utilization of destructors with PHP 5. Put in a simple way, during the aforementioned tutorial I showed you how to implement a destructor in a useful fashion. This is because I defined a highly generic user-handling class that included into its API a destructor method that was capable of displaying on the browser the methods and properties of a specific object prior to its corresponding deletion by the PHP interpreter.
Indeed, the use of destructors to keep track of the properties (and eventually the methods) of a determined object can be relatively helpful, especially in those situations where a specific PHP 5 application requires you to trace the status of some of its objects before they are removed by the PHP engine.
And now that I've spoken of keeping track of methods and properties of certain objects via their respective destructors, in this fourth article of the series I’m going to teach you how perform this process when working with multiple objects (remember that you already learned how to achieve this using only one class instance).
Hopefully, by the end of this installment you’ll be equipped with the required background to build a simple mechanism that will permit you to keep track of the properties and methods of a bunch of objects by using the functionality provided by their respective destructors.
With the preliminaries out of our way, let’s move forward and continue learning more useful features concerning the usage of destructors with PHP 5. You’ll have a very good time, that’s guaranteed!