PHP
  Home arrow PHP arrow Using the Observer Design Pattern with Static Data 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? 
PHP

Using the Observer Design Pattern with Static Data in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 9
    2007-09-17


    Table of Contents:
  • Using the Observer Design Pattern with Static Data in PHP 5
  • Handling user data via a single static property
  • Using a static property with the Observer pattern
  • Putting the data checking system to work

  • 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


    Using the Observer Design Pattern with Static Data in PHP 5
    ( Page 1 of 4 )

    In the vast terrain of object-oriented programming with PHP 5, working with static data members is an approach that provides developers with the capacity for building classes that are callable from outside the object context. It also lets them define properties that are shared by all the instances of those classes. If you're interested in learning how to put this powerful feature to work for you, then you should start reading this series of articles now!

    Introduction

    Welcome to the last tutorial of the series "Handling Static Data with PHP 5." By using a step-by-step guide, this series walks you through working with static properties and methods in PHP 5, and also shows you how to combine this static data with some of the most popular design patterns, such as "Factory" and "Observer."

    In the previous article, I went through the development of a basic example to demonstrate how the definition of a unique static property within a given class can facilitate the enchaining of different objects that belong to the class.

    This rather primitive example showed how a bunch of user-related objects could increment the value of a specified static property each time a new one was properly instantiated. It demonstrated the principle that stands behind defining a class property as static. It should also be noticed that this basic example can be used as a starting point to develop more complex PHP applications that also use static data, since the core concepts remain the same, regardless of the size of the project being developed.

    However, as I said before, defining a simple static property within a given PHP class to chain its different instances might seem extremely basic, not to mention that it's hard to find a concrete application of this approach in the real world. Thus, keeping in mind this idea, in this last installment of the series I'll show you how to use a static property, along with the programmatic model dictated by the observer pattern, to implement an expandable data validation system. This task might have an immediate application in a real situation.

    Thus, having introduced the subject of this final part of the series, let's move on together and see how to build the aforementioned data validation mechanism using a unique static property. Let's get started!



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

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





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