#native_company# #native_desc#

Templates – why and how to use them in PHP3 Page 3

By Sascha Schumann
on July 30, 2000



<HEAD><TITLE>Feature world - {PAGE_TITLE}</TITLE></HEAD>








<TR> <TH>name</TH> <TH>size</TH> </TR>










include "class.FastTemplate.php3";

function InitializeTemplates() {


    $tpl = new FastTemplate(".");

$tpl->define( array( page      => "page.tpl",

table     => "table.tpl",

table_row => "table_row.tpl" ) );


function ReadCurrentDirectory() {


    $handle opendir(".");

$filename readdir($handle)) {








function PrintPage($title) {



$tpl->parse(FINAL, "page");





Printpage("Yet Another Demo");


Speed Discussion

“Ok,” you might say, “that is all fine and nifty. But doesn’t it impact
the speed of my web site?”
Yes, your site will probably become faster. There is a simple reason
for that: Because you as the coder are focused on designing your
application and building code, your code will be more efficient, handling
the same task easier and quicker. So, you might add just another reason
to the above list why you should consider using FastTemplate in your
next PHP project.
If you just want to convert an existing web site, the performance hit
will probably not be noticed. I introduced a regex (short for “regular expression”)
cache into PHP 3.0.7 which helps in this special case. Because FastTemplate
uses a regex for every macro, each regex will be compiled only once and
the speed impact becomes negligible.