Re: Processing Code created on the fly
| From: | Jason Wong | Date: | Sat, 30 Mar 2002 05:35:28 +0000 |
| Subject: | Re: Processing Code created on the fly | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90750@lists.php.net to get a copy of this message | ||
On Saturday 30 March 2002 12:39, Jonathan Duncan wrote:
> Yeah, I have played with the eval function a bit, but it didn't seem to
> help much. Then again, I haven't ever used the eval function before so I
> may not know how to properly implement it. I have read the page for eval
> on php.net several times as well as the very helpful examples, but whenever
> I use eval, it just prints out the same stuff. By same stuff I mean wether
> I use eval or just the variable by itself it just prints out the contents
> of the variable. In the web page source it looks as if the contents were
> merely echoed because it still has the $'s and variable names. Any other
> ideas or examples on how to implement eval on this?
Well one thing you shouldn't do is use double-quotes when assigning strings
for later evaluation, particularly when they contain 'variables'.
Thus this does NOT work:
<?php
$doo = "$doo = 'dah';"; # $
eval($doo);
echo "Doo is $doo<br>";
?>
Whereas this does:
<?php
$doo = '$doo = \'dah\';';
eval($doo);
echo "Doo is $doo<br>";
?>
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
To program is to be.
*/