<? $foo='foo'; $bar='bar'; echo("foo is $foo; bar is $bar"); $myCode='$foo="checking eval statements"; '; $myCode.='$bar=str_replace(" ","--",$foo);'; eval($myCode); echo("foo is $foo; bar is $bar"); ?>
You could even do this:
<? $foo='$i++;'; $bar='eval($foo);'; $i=1; eval($foo); echo("i=$i"); eval($bar); echo("i=$i"); ?>
HTH
Bogdan
Decapode Azur wrote:
Is it possible to put PHP code in eval ? Or just vars ?
<?php
$string = 'The result of <?php $a=2; $b=3; $c=$a+$b; echo "$a + $b is $c"; ?>';
eval ($string);
?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php