PHP
  Home arrow PHP arrow The Sleep and Wakeup Magic Functions 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? 
Google.com  
PHP

The Sleep and Wakeup Magic Functions in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-06-16


    Table of Contents:
  • The Sleep and Wakeup Magic Functions in PHP 5
  • Review: the call magic function
  • Introducing the sleep and wakeup functions
  • The sleep and wakeup methods in action

  • 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


    The Sleep and Wakeup Magic Functions in PHP 5
    ( Page 1 of 4 )

    Magic functions are an important part of the numerous improvements and additions that were introduced originally in PHP 5. They can be extremely handy when it comes to simplifying the execution of complex tasks. This is the fourth part of a seven-part series that showcases some of the more useful magic functions and how to implement them.

    Ranging from overloading properties and methods of a class, including automatically overloading classes and triggering specific processes before destroying objects, magic functions can be used for doing all sorts of clever things. Some of these have been rather overlooked by many developers, quite possibly because they're not aware of their full potential.

    However, if you've been a patient follower of this series of articles and have read all of the preceding tutorials, then you're familiar with using some of the most relevant magic functions in concrete cases, including the "__set()," "__get()" and "__call()" trio, and the "__isset()" and "__ unset()" functions as well.

    In the last tutorial I explained how to overload a method of a basic class via the aforementioned "__call()" function, which, as you'll surely recall, is invoked behind the scenes by the PHP engine each time it finds a reference to a non-existent method of a class.

    Indeed, method overloading is a powerful approach that allows you to perform complicated tasks with a minimal amount of code, even when this benefit comes at the expense of making the code harder to read and maintain in many cases.

    The purpose of this series of article is to explore the most relevant PHP 5 magic functions, so it's time to talk about the ones that I plan to discuss in the next few lines. So, as this article's title suggests, in this fourth chapter I'm going to examine closely the "__sleep()" and "__wakeup()" functions, which are called automatically when an object is serialized and unserialized respectively.

    By the end of this article, you'll be armed with the right pointers to start using these functions inside your own PHP applications, so let's get started. 



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

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - 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 ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek