eval challenge
| From: | neko | Date: | Tue, 04 Mar 2003 10:01:19 +0000 |
| Subject: | eval challenge | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-138064@lists.php.net to get a copy of this message | ||
- define a string that has a function call in it (that returns a string)
that at the time of declaration is not in scope, eg
$str = "this is the name : \$node->getName()"; // $node is _not_ defined
currently, so we can't escape out
....
then, later on in the code, this string will be passed to a function that
has $node in scope, and that's when I want to eval the string to replace the
value.
$node = new Node($argwhatever);
eval("\$str=\"$str\";"); // $node is now in scope, so I'd really like
$node->getName to return something meaningful
Anyone able to solve this one? Yesterday I could achieve most other
requirements with eval, but this one has me stumped.
cheers,
neko