evaluating code with variables
if have a variable in your script, and in that variable is other variables, then when you set that variable then echo it, the values are there. The first variable is evaluated when set. Example:
$var1 = "test";
$var2 = "this is a $var1";
gives you "this is a test"
OK, that is the setup. Now the issue is that $var2 is a file (let's call it var2.file). So I want to put the file contents into $var2 and have it evaluated. But I do not want to echo it until later based on other things.
Last edited by Beach Bum; 11-08-2005 at 08:46 PM.
OK - got it - using my real variable names here it is:
EDIT >> The post converted the ' character in the last preg_replace, but you get the idea.
$header = htmlspecialchars(file_get_contents('../restricted/header.htm'));
eval("\$header = \"$header\";");
// $header = htmlspecialchars_decode($header); // php5 or use below code
$header = preg_replace('/</','<',$header);
$header = preg_replace('/>/','>',$header);
$header = preg_replace('/"/','"',$header);
$header = preg_replace("/'/","'",$header);
Last edited by Beach Bum; 11-08-2005 at 09:16 PM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)