PHP
  Home arrow PHP arrow Manipulating String Literals with Interpreter Classes 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

Manipulating String Literals with Interpreter Classes in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      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


    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
     

       

    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 2 hosted by Hostway
    Stay green...Green IT