PHP Template (smarty)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





i'm learning some PHP template classes, almost all of it using
str_replace() function.

they work by reading the template file *.tpl and then replace some
string/tags that having format like {FOO}

my question is: why they using this technique? i think that it eat
more resources by reading the *.tpl file, find & replace {FOO} tags,
and include it in php file that call the class.

why not just use a variable/array and embed it to the template file? i
giving example so you can understand what i mean.

============
template.tpl
============
<html>
<head>
<title>template example</title>
</head>
<body>
<? echo $table; ?>
</body>
</html>

============
script.php
============
<?php
$table = "<table>\n<tr>\n";
for (i=0; i<=5; $i++)
{
   $table .= "<td>$i</td>\n";
}
$table .= "</tr>\n</table>";

include ("template.tpl");
?>

best regards,
Markus






PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux