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  
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 
Moblin 
JMSL Numerical Library 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      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


    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

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





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