PHP
  Home arrow PHP arrow Manipulating String Literals with Inte...
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 
VeriSign Whitepapers 
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

Manipulating String Literals with Interpreter Classes in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2007-04-09

    Table of Contents:
  • Manipulating String Literals with Interpreter Classes in PHP 5
  • Handling literals
  • Defining a string interpreter class
  • Parsing string commands by using the StringInterpreter class

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Manipulating String Literals with Interpreter Classes in PHP 5


    (Page 1 of 4 )

    Among the huge variety of design patterns that can be easily implemented in PHP 5, the interpreter is one that might be particularly interesting to you. It allows you to build effortlessly the so-called parser layers. Welcome to the second installment of the series that began with “Building Interpreter Classes with PHP 5.” Made up of three parts, this series introduces the core concepts on this useful pattern, and also complements its theory with numerous educational hands-on examples.

    Introduction

    Stepping back for a moment to the preceding article of the series, I’m pretty sure that all the concepts deployed in that tutorial concerning the concrete implementation of the interpreter pattern in PHP 5 will be familiar to you now. However, if that’s not the case, let me remind you quickly how this pattern works, so you can grasp more easily all the code samples that I plan to include in this article.

    In plain terms, where this pattern is applied, there’s a class, usually called “interpreter,” which is responsible for parsing a predefined set of commands. These commands are sent out by one or more additional classes. As you can see, this definition is easy to understand because it is similar to the concept of parsers.

    However, building interpreter classes is by far a much simpler process than developing full-featured parsers. I hope to demonstrate this by showing you some didactical code samples, where this pattern will be mostly used as a simple yet efficient parsing layer.

    Bearing in mind that in the first article of the series I illustrated how to use an interpreter class to handle a group of fictional users, in this tutorial I’m going to go teach you how to utilize this pattern for manipulating a set of string processing classes.

    By the end of this tutorial, you should be equipped with a solid background in how the interpreter pattern works. This may be very useful to you, particularly if you’re taking your first steps into pattern-based programming with PHP 5.

    Now, having outlined the topics that will be covered in the next few lines, it’s time to move on and continue learning more on how to build interpreter classes. Let’s get started now!

    More PHP Articles
    More By Alejandro Gervasio


       · Over the course of this second installment of the series, you'll see how to use an...
     

       

    PHP ARTICLES

    - 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...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





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