PHP
  Home arrow PHP arrow Completing a Sample String Processor with Method Chaining
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? 
Google.com  
PHP

Completing a Sample String Processor with Method Chaining
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 1
    2009-10-28


    Table of Contents:
  • Completing a Sample String Processor with Method Chaining
  • Review: the string processor class
  • Replacing characters of a string with HTML entities
  • Replacing and reversing characters of a literal

  • 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


    Completing a Sample String Processor with Method Chaining
    ( Page 1 of 4 )

    In this third part of a 12-part series on method chaining, I complete the definition of the sample string processor class. This process will help reaffirm the concepts that you learned before regarding the definition and implementation of chainable methods in PHP 5.

    Method chaining is a simple, yet powerful, programming approach that permits you to write classes whose methods can be easily linked with each other, thus building a modular and highly-compact API. Logically, as with other methodologies, chainable methods are not a proprietary feature of a particular programming language, but rather an approach that can be used for developing both client and server-side web applications, and desktop programs as well.

    Fortunately, PHP developers like you also can take advantage of the benefits of using method chaining when working with the object-oriented paradigm. In this series of articles you'll find numerous examples that not only will introduce you to the basics of this approach, but will show you how to use it in the context of real-world applications.

    Naturally, if you already read the two preceding tutorials of the series, then at this stage you have a clearer idea of how to build chainable methods in PHP 5. In  those articles I developed a basic string processor class, which implemented some simple chainable methods for applying different filters to an incoming string.

    In addition, it's fair to recall that this sample class defined a factory method (also chainable), which allowed you to create a singleton of the string processor without having to call its constructor directly.

    However, it'd be pretty instructive to expand the existing functionality of the mentioned class by adding a few additional methods to it, which will also be  completely chainable. In this third chapter of the series I'm going to finish developing this string processor class by incorporating into it some chainable methods that will be tasked with replacing characters in an inputted string with their equivalent HTML entities, and with for reversing their value as well.

    Now, it's time to continue creating more examples on using method chaining in PHP 5. Let's jump in!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek