Location: PHPKode > scripts > ft classes > ft-classes/static_sample.php
<?php
include_once("cls_ft.php");
$start=microtime();
//get the ft object
$ft=new FastTemplate(".");
//define template files.
$ft->define(array('main'=>'a_static.html','row' => 'b_static.html'));

//parse the 5000 rows in a for loop and assign some values
for($i=1;$i<=5000;$i++)
{
    $ft->assign('CELL_TEXT',"row:.$i");
    //now parse the row in "append" mode.
    //this is done by adding a "."(dot) in front of "row" template
    //we send the output to TABLE_ROWS,the tag from the "main" template
    $ft->parse('TABLE_ROWS','.row');
}

//now assign all values for the "main" template and parse this too.
$ft->assign('HEADER','Two static templates 5000 rows test');
$ft->parse('MAIN_CONTENT','main');

$end=microtime();
echo "Printed $i row(s) in ".microtime_diff($end,$start)." secconds<br>";

//print the content
$ft->ft_print('MAIN_CONTENT');



function microtime_diff($a,$b) {
     list($a_micro, $a_int)=explode(' ',$a);
     list($b_micro, $b_int)=explode(' ',$b);
     if ($a_int>$b_int) {
        return ($a_int-$b_int)+($a_micro-$b_micro);
     } elseif ($a_int==$b_int) {
        if ($a_micro>$b_micro) {
           return ($a_int-$b_int)+($a_micro-$b_micro);
        } elseif ($a_micro<$b_micro) {
           return ($b_int-$a_int)+($b_micro-$a_micro);
        } else {
           return 0;
        }
     } else { // $a_int<$b_int
        return ($b_int-$a_int)+($b_micro-$a_micro);
     }
  }
?>
Return current item: ft classes