Home arrow PHP arrow Persistent Objects and Different Session Variables in PHP 5

Persistent Objects and Different Session Variables in PHP 5

Despite its rather intimidating name, persistent objects represent a pretty simple concept applied very often in software development. It's aimed at creating structured entities that can maintain their status across different stages of an application. This six-part series will take the mystery out of persistent objects so you can use them in your own applications.

TABLE OF CONTENTS:
  1. Persistent Objects and Different Session Variables in PHP 5
  2. Building a basic persistent class in PHP 5
  3. Saving class instances to different session variables
  4. Building a wrapping example
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
September 21, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

When using PHP 5 for developing web-based programs, creating this kind of object is even simpler. In most cases, the creation process is reduced to defining classes that are simply capable of keeping their state through several HTTP requests, in order to overcome the stateless nature of this protocol.

Naturally, popular storage mechanisms long available on the web like database tables, text files and even cookies are frequently used to save instances of a class. This implies that some objects may be more persistent that others, even when this characteristic is only relevant in the context in which theyíre utilized.

However, as with many other topics related specifically to web development, building persistent objects in PHP 5 is a subject thatís definitely much better understood by example. So, in the first part of this series of articles I demonstrated how to define a basic class, which was provided with the ability to save an instance of itself to a predefined session variable, in this way maintaining its state across several web pages.

There are, however, a few issues that must be fixed regarding the way that this persistent class was initially defined. First, itís necessary to show how to restore an instance of the class on a different web page, and second, it must have the ability to use different session variables for saving its instances, thus enhancing its flexibility.

Therefore, in this second installment of the series Iím going to show how to address the aforementioned issues. Letís get started right now!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: