Home arrow PHP arrow Keeping Track of Objects when Using Destructors in PHP 5

Keeping Track of Objects when Using Destructors in PHP 5

Among the improvements that were introduced into the object model of PHP 5, class destructors are quite possibly, one of the easiest to learn and implement. As you may have heard, a destructor is a special kind of method that is called automatically by the PHP interpreter right before destroying a particular object. So if you’re interested in learning how to use them in your own PHP 5-driven applications, you should start reading this article series!

TABLE OF CONTENTS:
  1. Keeping Track of Objects when Using Destructors in PHP 5
  2. When the order really matters: working with multiple destructors
  3. Retrieving useful information about a particular object before it's removed
  4. Seeing the improved User class in action
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
January 30, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

This is the third chapter of the series "Understanding destructors in PHP 5." In the different tutorials that comprise the series, you'll find the right pointers to start utilizing destructors within your PHP 5 classes. And in addition to learning the corresponding theory regarding these useful methods, you'll be provided with copious hands-on examples aimed at demonstrating, in a practical way, how to get the most out of them.

Now that you're well aware of the main subject of this series, I'm going to take a few minutes of your valuable time to rehash the topics that were discussed in the last article. As you'll probably recall, during the course of that article, I went through the definition of a highly generic user handling class, which when implemented at a basic level, is a primitive destructor method.

The purpose was simply to demonstrate the order in which multiple destructors were called by the PHP interpreter, when using some of the user handling objects that I mentioned earlier. The final result of this testing process was pretty obvious: the PHP engine used the same order in which these objects were constructed, to destroy them; something that was clearly shown by the respective destructors.

Even though this particular example doesn't have a direct application in real world conditions, it should help you understand the priority scale used by the PHP parser when it comes to calling multiple destructors during the execution of a given application.

So far, so good. Now that you hopefully remember all the details concerning the use of several destructors in PHP 5, it's time to continue learning more about these helpful methods. Therefore, in this third part of the series, I'm going to show you how to retrieve some useful information about a specific object, including its properties and methods, prior to its being destroyed by the PHP parser via the implementation of a simple destructor.

Want to see how this will be achieved? Jump into the next few lines and begin reading now!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: