PHP
  Home arrow PHP arrow Using a Template Processor Class 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? 
Google.com  
PHP

Using a Template Processor Class in PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2006-05-09


    Table of Contents:
  • Using a Template Processor Class in PHP 5
  • Getting started using the “TemplateProcessor” class: a quick look at its definition
  • Parsing template files: defining the input tags for the “TemplateProcessor” class
  • Going one step further: seeing the “TemplateProcessor” class in action

  • 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


    Using a Template Processor Class in PHP 5
    ( Page 1 of 4 )

    Welcome to part two of the series “Separating logic from presentation.” Comprised of three articles, this series walks you through the development of an extensible template processor in PHP 5, which you might find quite useful for separating the logic of your PHP applications from their visual presentation.

    Introduction

    As you’ll know (and assuming that you already took a look at the first article of the series), in the first tutorial I explained how to build in a PHP 5-driven template processor class. It exposed a few handy methods aimed at parsing the respective template file passed as an argument, by replacing its placeholders with actual data provided as an array structure.

    If the above concepts are quite familiar to you, then you’ll recall that I provided my template processor class with certain interesting features, such as the ability to  recursively replace placeholders, parse dynamic PHP files, process MySQL result sets, and run PHP code included as part of the input tags array. Of course, as I said before, the class can be easily expanded, either by defining more methods or modifying the existing ones, in order to fit the particular requirements of more demanding applications. As in most cases, deciding when and how to expand the template processor class will depend on the size and complexity of the Web project where the class will be included.

    Now, bringing our attention to this second installment of the series, I’ll show you how to use the template processor class by coding some sample codes, so you can have an exact idea of how to include this class either in your own PHP projects or as part of a larger shared application.

    Having defined the goals for this article, let’s leap forward and begin learning more about how to take advantage of this PHP 5 template processor class. Let’s go!



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

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - 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





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