PHP
  Home arrow PHP arrow Page 4 - Retrieving Information on Several Obje...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 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

Retrieving Information on Several Objects with Destructors in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2008-02-06

    Table of Contents:
  • Retrieving Information on Several Objects with Destructors in PHP 5
  • Keeping track of a single object
  • Working with different user handling objects
  • Displaying data related to different objects using one single destructor

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Retrieving Information on Several Objects with Destructors in PHP 5 - Displaying data related to different objects using one single destructor


    (Page 4 of 4 )

    As I promised you in the section that you just read, here’s the output generated by the script developed before. As you’ll see in a moment, it displays not only the first and last names and email addresses of those fictional users, but prints their respective methods and properties as the destructor is being called by the PHP interpreter.

    Having explained that, please take a look at the following screen results:


    First Name: John

    Last Name: Doe

    Email: john@domain.com

    Complete user information: First Name: John Last Name: Doe Email Address: john@domain.com


    First Name: Mary

    Last Name: Smith

    Email: mary@domain.com

    Complete user information: First Name: Mary Last Name: Smith Email Address: mary@domain.com


    First Name: Susan

    Last Name: Norton

    Email: susan@domain.com

    Complete user information: First Name: Susan Last Name: Norton Email Address: susan@domain.com

     

    Properties of object being destroyed

    firstName=John

    lastName=Doe

    email=john@domain.com

     

    Methods of object being destroyed

    Method Name: __construct()

    Method Name: getFirstName()

    Method Name: getLastName()

    Method Name: getEmail()

    Method Name: getAll()

    Method Name: __destruct()

     

    Properties of object being destroyed

    firstName=Mary

    lastName=Smith

    email=mary@domain.com

     

    Methods of object being destroyed

    Method Name: __construct()

    Method Name: getFirstName()

    Method Name: getLastName()

    Method Name: getEmail()

    Method Name: getAll()

    Method Name: __destruct()

     

    Properties of object being destroyed

    firstName=Susan

    lastName=Norton

    email=susan@domain.com

     

    Methods of object being destroyed

    Method Name: __construct()

    Method Name: getFirstName()

    Method Name: getLastName()

    Method Name: getEmail()

    Method Name: getAll()

    Method Name: __destruct()


    As illustrated above, by using only one simple destructor, it’s perfectly possible to display data related to the structure of some trivial user handling objects prior to the corresponding deletion by the PHP engine. Short and effective!

    So far, so good. At this point, you hopefully have a more solid background on using destructors with PHP 5 to collect data concerning the structure of certain objects. In addition, you’re free to use all of the code samples built here, with the purpose of expanding your skills in utilizing these useful methods.

    Final thoughts

    In this fourth part of the series, you learned, with the help of a few easy-to-follow examples, how to exploit the functionality provided by destructors to retrieve information about a bunch of objects before they were removed from memory.

    But in this case, it’s fair to mention that all of the examples shown so far have used destructors that are called automatically by the PHP engine. Therefore, in the final article of the series I’ll teach you how to manually trigger a destructor method before giving this chance to the interpreter.

    Intrigued about how this will be done? Don’t miss the last chapter of this journey!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway