PHP
  Home arrow PHP arrow Page 7 - Web Development With PHP FastTemplate
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

Web Development With PHP FastTemplate
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 9
    2001-09-05


    Table of Contents:
  • Web Development With PHP FastTemplate
  • Who Am I?
  • Proofing The Pudding
  • You've Got Mail
  • Repeat Customers
  • Flavour Of The Month
  • A Strict() Master
  • Musical Chairs
  • A Rose By Any Other Name...

  • 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


    Web Development With PHP FastTemplate - A Strict() Master
    ( Page 7 of 9 )

    While the methods discussed above will suffice for most of your FastTemplate requirements, the class also comes with a bunch of ancillary capabilities.

    The strict() method is used to display an error if FastTemplate finds template variables without any values assigned to them; these undefined variables will also appear as is in the final output.

    <? // strict error checking $obj->strict(); ?>
    The opposite of this is the no_strict() method, which replaces these unassigned variables with empty strings.

    <? // turn off error checking $obj->no_strict(); ?>
    The fetch() method returns the raw data which results from a parse() operation. Consider the following:

    <? // parse templates $obj->parse(RESULT, "list"); // print echo $obj->fetch("RESULT"); ?>
    The clear() method is used to clear variables.

    <? // parse templates $obj->parse(RESULT, "list"); // clear $obj->clear("RESULT"); // prints nothing $obj->FastPrint("RESULT"); ?>
    The get_assigned() method is used to obtain the value of any FastTemplate variable.

    <? $obj->assign("EMAIL", "jdoe@somewhere.com"); // returns "jdoe@somewhere.com" echo $obj->get_assigned("EMAIL"); ?>
    And finally, the utime() function comes in handy when you need to measure script execution time.

    <? // list.php - item list // include class file include("class.FastTemplate.php3"); // instantiate new object $obj = new FastTemplate("./tmpl/"); // get start time $begin = $obj->utime(); // assign names for template files $obj->define(array( "list" => "list.tpl", "list_item" => "list_item.tpl" )); // get item list // assume it looks like this.. $items = array("vanilla", "pineapple", "strawberry", "chocolate chip", "peach", "banana", "grape"); // build LISTCONTENT variable by concatenation of multiple instances of "list_item" template for ($x=0; $x<sizeof($items); $x++) { $obj->assign("ITEM", $items[$x]); $obj->parse(LISTCONTENT, ".list_item"); } // parse templates $obj->parse(RESULT, "list"); // and print $obj->FastPrint(RESULT); // get end time $end = $obj->utime(); // print script execution time echo "Done in " . sprintf("%01.3f ", ($end - $begin)) ." seconds."; ?>


     
     
    >>> More PHP Articles          >>> More By icarus, (c) Melonfire
     

       

    PHP ARTICLES

    - 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 ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT