...

View Full Version : Eval & Writing php variables to a new file



adbox
01-28-2010, 10:08 PM
Hey

I have built a template html variable:
$html

and want to setup some variables within that $html variable so when I write it I can call the php variables from within that file.

Here is an example of how far I have got:


$html .= "<?php \$var1='".$var1."'; ?>";
$html .= "<?php \$var2='".$var2."'; ?>";

...

eval("\$html = \"$html\";");
$fh = fopen($file, 'w');
fwrite($fh, $html);
fclose($fh);

ssonawa
01-29-2010, 06:18 AM
You can do that.

For example -
<?php
$string = "beautiful";
$time = "winter";

$str = 'This is a $string $time morning!';
echo $str. "<br />";

eval("\$str = \"$str\";");
echo $str;
?>

Refer http://www.w3schools.com/php/func_misc_eval.asp for more detailed info.

:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum