PHP
  Home arrow PHP arrow Using the Sleep and Wakeup Functions t...
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 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

Using the Sleep and Wakeup Functions to Serialize Objects in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2006-06-13

    Table of Contents:
  • Using the Sleep and Wakeup Functions to Serialize Objects in PHP
  • A quick look at how to define self-saving objects
  • Using the “__sleep()” and “__wakeup()” magic functions
  • Creating persisting objects

  • 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


    Using the Sleep and Wakeup Functions to Serialize Objects in PHP


    (Page 1 of 4 )

    Curious about how to serialize your objects inside your beautifully-crafted application? Look no further. Welcome to the second part of the series "Serializing objects in PHP." This set of three tutorials introduces the fundamentals of objects serialization, and teaches you some advanced concepts regarding this approach, such as using objects in sessions and storing them in database tables.

    Introduction

    As you'll surely recall, over the previous article, I explained the basics of serializing objects in PHP. I showed some code samples that illustrated in a simple way the process of converting objects to their string representation (called serialization). I also showed how to reverse this process (that is unserialization), in order to restore these objects to their original state. In the several examples that you saw before, I also exposed some interesting concepts involved in object serialization, such as constructing objects that are capable of saving and restoring themselves via their own methods, which are commonly called self-saving objects.

    As a matter of fact, one of the best things about serializing objects in PHP is that this fairly simple concept can be used as the starting point to tackle more advanced concepts, including those related to an object's persistence and its storage in database tables. In addition, if you've been working with sessions for a while, then you'll know that the PHP built-in session handling mechanism serializes and unserializes objects behind the scenes, whenever they're registered during a particular session, which means that object serialization is indeed an important topic that must be addressed appropriately.

    Now, after refreshing the concepts that I deployed in the first part of this series, it's time to focus on the topics that I'll cover in this article, so you'll know what to expect before you continue reading. In this second part, I'll explain how to use objects in conjunction with the "__sleep()" and "__wakeup() magic functions respectively, in order to get the most out of them.

    Having defined the topics for this new tutorial, let's move on and continue learning more about object serializing in PHP. Let’s go!

    More PHP Articles
    More By Alejandro Gervasio


       · If you found the first article interesting, then this second one will be hopefully...
       · "If you found the first article interesting " -- would you happen to have a title...
     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...





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