On Fri, 29 Mar 2002, 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?
You might want to think carefully about what you're trying to achieve
(after looking at your code, I certainly don't have the faintest idea, nor
do I get why it can't be accomplished using functions). eval() is usually
a last-ditch measure.
In any case, here's an example of how to use it:
$a = 3;
$b = 4;
$c = "\$a+=\$b;";
Note that you have to pay a lot of attention to which dollar signs you
escape and which you don't. With sufficiently complicated substitutions
you can end up with a mess of dollar signs and backslashes that will give
you a nosebleed.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php