Re: eval
| From: | Bogdan Stancescu | Date: | Fri, 01 Aug 2003 09:27:15 +0000 |
| Subject: | Re: eval | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157911@lists.php.net to get a copy of this message | ||
You can put whatever you want in eval:
<?
$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); ?>