Forum Moderators: coopster
a simple problem
i have HTML code stored in my database fields , i just want to have a script so that whenever that script is called it executes that code as PHP Code.. i am sure your first answer would be eval() but this is a bitt different problem.
leme explain. Lets say we have this code
<html><head><title><? ShowBodyOfThePage();?>
</title></head>
<body>
<? ShowBodyOfThePage();?>
</body>
</html>
Can any one share his expetise of how we can write a script to which if i send this string
"<html><head><title><? ShowTitleOfThePage();?>
</title></head>
<body>
<? ShowBodyOfThePage();?>
</body>
</html>"
it returns to me the same html but with that php function getting executed and replaced with whatever the function returns.
Please feel free to advice if the same thing can be done in some other way i mean if for example your method needs to remove "<?>" tags or anything or put this string in any echo.
Assistance is Much needed and will be Highly Appreciated.
Posting it here, in case anyone else needs it:
<?
$content="<?echo 'PHP:yes this works! <br>'?>HTML:Yes this Works too!";
$tmpfname = tempnam ("/tmp", "FOO");
$fp = fopen($tmpfname, "w");
fwrite($fp, $content);
fclose($fp);
include($tmpfname);
unlink($tmpfname);
?>