function fetch_template($filename) {
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
This is just code to apply the contents of a file into a string. In this case that string is $contents. However, lets say...
$contents contains "Welcome Back, $name"
When this is echoed it comes out exactly as above "Welcome Back, $name"
I want it to parse(I think) the variable so that it will return what the string $name holds instead of returning $name.
For example if the script was
$name = "Alfred";
fetch_template("welcome.html");
function fetch_template($filename) {
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
echo $contents;
and welcome.html contains this.
welcome back, $name
I want that to echo:
welcome back, Alfred
not
welcome back, $name.
I know there is some function that will do this, I've used it before, but it's been about 11 1/2 months since I looked at php so any help here would be much appreciated.
Thanks a lot.