Hi guys
When i program displays i like to use templates.. i design templates in dreamweaver, and save them as HTML files.
my templates contains something like this:
<b>My Name is ::name::</b>
Then in php, i load the template file with
file_get_contents command..
then i do a preg_replace routine, replacing all instances of ::name:: with $name and ::age:: with $age, and so forth..
I was wondering if there was a way for me to do away with the CPU intensive preg_replace routine, and do something like this:
my template would look like
<b>My Name is $name</b>
and all i should have to do is echo it outl like so..
echo $template_contents;
the idea is to have it seem as if my codes looked like this:
echo "<b>My Name is $name</b>";
but my output isnt as expected..
for example when i call
display.php?name=tea
the output is:
[b]My Name is $name[/b]
instead of
[b]My Name is tea[/b]
i guess this is because my $template_contents variable is treated like a packaged string of some sort where in the real variables ("$name") arent processed anymore...
I tried doing:
echo eval($template_contents);
but that didnt work
any ideas?
tea