PHP
  Home arrow PHP arrow Implementing Destructors with Multiple Objects in PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Implementing Destructors with Multiple Objects in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2008-01-23


    Table of Contents:
  • Implementing Destructors with Multiple Objects in PHP 5
  • Handling user-related data with a simple PHP 5 class
  • Working with multiple objects by redefining the destructor of the previous “User” class
  • Finding out the order in which several destructors are called by the PHP interpreter

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Implementing Destructors with Multiple Objects in PHP 5
    ( Page 1 of 4 )

    Welcome to the second installment of the series “Understanding Destructors in PHP 5.” Whether you’re a PHP programmer who’s making their first steps in the area of professional PHP development, or an experienced developer with a solid background in object-based PHP programming, this article series can provide you with an approachable guide for using destructors in PHP 5-controlled development environments.

    If you’re starting to get familiar with the numerous features incorporated into the improved object model of PHP 5, then you may have already heard about class destructors. But what are they? Simply put, a destructor is a method defined by a given class that will be automatically called by the PHP interpreter before destroying any instance of that particular class.

    Indeed, they can be quite useful for tracking the status of objects during the execution of different scripts. Therefore, if you’re interested in learning how to work with destructors within your own PHP 5 classes, then this group of articles might be what you’re looking for.

    Now that I've introduced you to the main subject of this series, I’d like to spend a few moments rehashing the items we discussed in the last article regarding the basic utilization of destructors with PHP 5. As you’ll probably recall, during that particular tutorial I walked you through both the theoretical and practical concepts concerning the definition and implementation of a simple destructor method within a sample class.

    In that specific case, I utilized a trivial “User” object to show how its corresponding destructor was called right before destroying the object in question. In this way I illustrated how the functionality of destructors can be exploited using a basic approach.

    Naturally, destructors can be used in all sorts of clever ways in the context of a given PHP 5 application, mostly in those cases where it’s necessary to keep track of the status of certain objects prior to their being destroyed by the PHP interpreter. Nevertheless, this is undoubtedly a more complex topic that will be discussed in detail in upcoming articles of the series. So for the moment, I’m going to continue at my own pace, and consequently, in this second chapter you’ll learn how to work simultaneously with multiple classes that concretely implement their respective destructors.

    The subject is indeed very interesting, so I think it's time to move forward and keep learning more useful things concerning the usage of destructors with PHP 5. Let’s go!



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

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT