PHP
  Home arrow PHP arrow Executing Destructors Manually 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

Executing Destructors Manually in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2008-02-13


    Table of Contents:
  • Executing Destructors Manually in PHP 5
  • Triggering a destructor manually
  • Calling multiple destructors manually
  • Emulating destructors in PHP 4

  • 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


    Executing Destructors Manually in PHP 5
    ( Page 1 of 4 )

    Welcome to the final chapter of the series “Understanding Destructors in PHP 5.” In consonance with this article’s title, this series walks you through the basics of utilizing class destructors in object-based applications and also provides you with a decent number of hands-on examples, so you can start incorporating these useful methods into your PHP 5 classes with minor efforts.

    If you’re a PHP developer who has spent a considerable amount of time using the set of brand new features incorporated into the object model of PHP 5, then there’s the possibility that you’ve already worked with class destructors. However, you may want to refresh their foundations or simply fill some gaps regarding their adequate implementation, so don’t hesitate to start reading this article series now!

    Now that you hopefully have a clear idea on the purpose of this article series, it’s an appropriate moment to make a brief recapitulation about the items that were discussed in great detail during the previous tutorial of the series. As you’ll surely recall, in that particular installment I demonstrated how to retrieve useful information about a few user handling objects, such as their respective properties and methods, prior to being removed by the PHP engine.

    This process was performed successfully by way of a single destructor method whose implementation consisted first of iterating over the properties and methods of a particular object, and then displaying this data on the browser. By using this simple, yet effective, approach it was possible to build a mechanism that printed structural information on a specific object onto the screen right before being destroyed by the PHP interpreter.

    All right, at this point I should assume that implementing destructors in a useful way is now a familiar concept to you, which may lead you to erroneously think that the topic doesn’t bear further discussion. Well, not so fast, since there’s an important point that still remains uncovered and here it comes:

    As you learned so far, destructors were called automatically by the PHP engine before finishing the execution of a determined script. However, did you ever think that these methods could be forced to run manually? Yes, you’re correct! If you purposely delete an object that implements a destructor, logically it will be called without the need to abruptly terminate the execution of a given script. Sounds quite interesting, right?

    Therefore, in this final tutorial of the series I’m going to show you how to manually trigger a destructor, and in addition you’ll learn how to emulate the behavior of this magic method when using PHP 4.

    Are you ready to tackle this last chapter of this educational journey? Let’s get started!



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

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





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