Forum Moderators: coopster
$mystr = 'test';
$str1 = 'This is a '.$mystr.'<br />';
$str2 = 'This is another '.$mystr.'<br />';
echo $str1;
echo $str2;
Why wouldn't you just do something like this?
Actually, I'm trying to add a function to the template library I'm using, so that I can store the templates in a database as opposed to a file. I just put up a simplified example of what I'm trying to accomplish.
I could probably do it as a dynamically generated include file, but I'd rather not do it that way.
Manual [us.php.net]
How about replacing the opening and closing tags with something else, and converting back to the tags when needed.
As for the insecurity of the eval() function, I don't remember ever using it in production code before, but was considering that it could be a possibility in this case.
But my best option might be use a different library for this. I'd still like to know if it is doable.
Thanks for the input.