PHP
  Home arrow PHP arrow Using the Observer Design Pattern with...
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
OLM
 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: 4 stars4 stars4 stars4 stars4 stars / 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:
      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

    Virtual Tradeshows by Ziff Davis Enterprise - A Unique Opportunity to Connect with IT Experts, Access Information, and Gain Insight on today's Technology

    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


       · This final tutorial of the series explains how to use a static property shared by...
     

       

    PHP ARTICLES

    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway