PHP
  Home arrow PHP arrow Building Interpreter Classes with PHP ...
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
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

Building Interpreter Classes with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-04-02

    Table of Contents:
  • Building Interpreter Classes with PHP 5
  • The basics of implementing the interpreter pattern
  • Parsing predefined commands
  • Seeing the interpreter pattern 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

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    Building Interpreter Classes with PHP 5


    (Page 1 of 4 )

    If you have ever written an application that primarily parses commands -- and who hasn't? -- keep reading. As is often the case, pattern-based programming makes this task easier. In this first part of a three-part article series, you'll learn the basic concepts surrounding the Interpreter pattern, with plenty of hands-on examples.

    Introduction

    In the vast and fascinating terrain of web development, working with applications whose primary task is to parse commands happens very frequently. Only think about this concept for a moment, and you'll quickly realize that every day you're dealing with some kind of parser, ranging from your own browser that interprets (X)HTML, CSS, XML, JavaScript code, etc. to your loyal PHP module that parses your neatly-crafted web applications.

    Actually, the concept of a parser is VERY old, but the impressive advance of technology has brought it to us in a variety of applications that sometimes exceed our imagination. However, it's not my intention to discuss here the influence of parsers on mankind, since it'd be rather irrelevant to the purposes of this article, and possibly it'd also be boring to you.

    Instead, I'd like analyze this interesting topic from a practical point of view, and ask you the following question: how many times have you found yourself developing a web application that was intended to interpret a certain number of predefined commands? Certainly, the answer might be dozens, even hundreds of times.

    But, what if I extend this concept one step further and tell you that it's possible to apply it in the context of pattern-based programming with PHP? Yes, you guessed right. Among the numerous design patterns available out there, there's one called "Interpreter." As its name suggests, it has the capacity to parse specific commands to perform a set of predefined tasks.

    Does this sound a bit confusing? Fear not, because building an interpreter class with PHP is a no-brainer process that can be achieved with only minor efforts. In plain terms, when the interpreter pattern is applied, on one hand there's a class that defines a set of commands that will be parsed, while on the other hand, there are some additional classes that are responsible for sending these commands to the interpreter. Now, the concept sounds much simpler, right?

    Naturally, if you're anything like me and want to see different hands-on examples on how to create interpreter classes with PHP, then I've got good news for you. In this series, which is comprised of three articles, I'll provide you with numerous code samples showing how to implement this useful pattern, ranging from building a simple application for managing user information to creating a decent blogger.

    Now, having introduced the subject of this series, let's start learning together how to build interpreter classes with PHP 5. It's going to be a truly instructive experience!

    More PHP Articles
    More By Alejandro Gervasio


       · Over the course of this first part of the article series, you'll learn the basic...
     

       

    PHP ARTICLES

    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...




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