hi there,
I'm trying to import a file (with fread()) with "holders" for variables in it, to be outputted using echo, with the variable values in it. The purpose of this is to be able to read in HTML templates which then get populated with the values in them. Let me illustrate:
reader.php:
<?
$variable = "foobar!";
$filename = "htmltemplate.html";
$fp = fopen($filename,"r");
$contents = fread($fp, filesize($filename));
echo "$contents";
fclose($fp);
?>
htmltemplate.html:
<tags>$variable</tags>
what i would expect to be the output of reader.php is "<tags>foobar!</tags>", as that would be the output of echo "<tags>$variable</tags>";
so i guess this variable substitution on execution of echo doesn't work in this instance. Does anyone know a way this can be made to work? I used to do it in perl with some regular expressions, but that was messy and i'm hoping someone has done something like this already 🙂
thanks in advance,
david