PHP
  Home arrow PHP arrow Introducing Visitor Objects in PHP 5
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 
Moblin 
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

Introducing Visitor Objects in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2006-08-02

    Table of Contents:
  • Introducing Visitor Objects in PHP 5
  • An introductory example
  • Defining another sample class
  • Defining the structure of a visitor
  • A visitor object in action

  • 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


    Introducing Visitor Objects in PHP 5


    (Page 1 of 5 )

    Although the article’s title may seem a bit intimidating, the truth is that things are much simpler than you think. Like many other programming languages, PHP also allows you to construct and use visitor objects with minor hassles. But, before I go deeper into the subject, first let’s ask ourselves the following question: what are visitor objects, after all?

    Introduction

    Well, if you've been using design patterns for a while in your PHP applications, then you've probably heard about the Visitor pattern. If you haven't yet, let me give you a short description of what this pattern does. In simple terms, when it's applied appropriately, the pattern allows you to build up objects that literally visit other objects to obtain information about the target objects. This process is usually done by inputting the visitors into the visited objects via a concrete method. 

    To put it simply way, suppose that you have a bunch of objects that represent, in the software universe, the profiles of several users. This example looks pretty familiar, doesn't it? Well, it's possible to create a set of objects that "visit" these users and obtain certain information related to them, such as First and Last Name, user IDs, email addresses, and so forth. The exciting aspect of this situation is that this entire process can be performed programmatically, by using some simple classes, and as you know, PHP makes working with objects a no-brainer task.

    So that's a small portion of theory of building visitor objects. Nevertheless, you'll agree with me that one of the most interesting aspects of design patterns is precisely their practical side. Therefore, considering this undeniable fact, in conjunction with your permanent wish for extending your background in object-oriented programming with PHP, over the course of this series I'll be showing you some useful examples of how to build visitor objects, and more specifically how to include them in real-world applications.

    Assuming that creating visitor objects with PHP has already caught your attention, let's introduce ourselves to the subject and start learning more about it.

    More PHP Articles
    More By Alejandro Gervasio


       · In this first installment of the series, you'll learn how to apply the visitor...
       · Alejandro,Thank you for writing such high quality material. I can't remember...
       · Hi Larry,Well, I guess this will be rather redundant but I thank you for all the...
     

       

    PHP ARTICLES

    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP





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