PHP
  Home arrow PHP arrow Saving Class Instances to Files with Persistent Objects
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

Saving Class Instances to Files with Persistent Objects
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2009-09-22


    Table of Contents:
  • Saving Class Instances to Files with Persistent Objects
  • Review: a basic persistent class
  • Saving class instances to a text file
  • Retrieving an object in a different PHP file

  • 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


    Saving Class Instances to Files with Persistent Objects
    ( Page 1 of 4 )

    Welcome to the third part of a six-part series on building persistent objects in PHP 5. Through a decent variety of code samples, this series provides you with the right pointers to start creating objects that can save themselves to a persistent storage mechanism, including simple cookies, plain text files, and MySQL database tables.

    Though it may sound scary and a bit intimidating, creating objects in PHP 5 that can maintain their state through a number of HTTP requests is an extremely simple process. It only requires an intermediate background in the object-oriented paradigm, along with a basic understanding of how to serialize/unserialize objects.

    So, if you’re a PHP developer who wants to master the key concepts that surround the creation of this kind of object without having to spend endless hours reading the PHP manual, then this group of articles may be the material that you’re looking for.

    And now that you've been introduced to the main goal of the series, it’s time to review the topics that were covered in the last article. In that tutorial I explained  how to build a basic PHP 5 class which was capable of saving an instance of itself to a specified session variable. This ability allowed it to persist across different web pages.

    Also, it’s worth mentioning that this class implemented a static factory method, which allowed it to retrieve class instances in a truly painless way, without our having to explicitly code any constructor.

    Though, as I said a few moments ago, a persistent object can also use different mechanisms to maintain its status; that naturally includes text files. Thus, in this third chapter of the series, I’m going to discuss how to build a class that stores instances of itself in a specified file.

    Are you ready to learn more on this topic? Start reading right now!



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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - 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...





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