Hi !!!
I'm using the following template function to parse variables:
<?
###########################################################
Function: Simple Template-Engine
###########################################################
Function template($template) {
Global $title;
$tempath="c:/Apache/htdocs/templates"; //template path.
$tempfile = fopen("$tempath/$template", "r"); // open the template file.
while(!feof($tempfile))
{
$temp = fgets($tempfile,255); // convert template in a string.
include("tags.php"); // this file will replace {tags} with variable values in current string.
print($temp); // print the parsed string.
}
fclose($tempfile);
}
?>
--File tags.php--
<?
#TAGS.
$temp = str_replace("{title}", $title, $temp);
?>
Well, this work with no problems, but I need a enhancement on this function to allow execute and include php codes also. Actually the $temp is only printable.
print($temp); // print the parsed string.
Is there any way to improve this ???
Regards,
marcoBR