[PHP] Re: eval help

2003-03-03 Thread neko
ok - my latest in the eval saga is this: I want to be able to eval a function call anywhere in the string supplied, and the function call is not in scope when the string is defined. So -- somewhere in my code I wanted something like this: $string = "testing nodename: \$node->getName() pagename:

[PHP] Re: eval help

2003-03-03 Thread neko
we're in the pipe, 5-5-5."); $str = "Hello, \$name"; $str2 = "Hello, \$arr[0]"; $str3 = "Hello, \$arr2[".NAME_TAG."]"; echo doEvalWithVarsInScope($str); echo doEvalWithVarsInScope($str2); echo doEvalWithVarsInScope($str3); } function doEvalWithVarsInScope($str) { echo("trying to e

[PHP] Re: eval help

2003-03-03 Thread neko
Actually, I just realised that what I want to accomplish is different from my example - the main issue is with scope: we're in the pipe, 5-5-5."); $str = "Hello, \$name"; $str2 = "Hello, \$arr[0]"; $str3 = "Hello, \$arr2['name']"; echo doEvalWithVarsInScope($str); echo doEvalWithVarsI

Re: [PHP] Re: eval help

2003-03-03 Thread neko
Thanks Dan - I just worked this out before reading your solution! :) $str4 = "Hello, ".$arr2['name']; cheers and thanks to all - lets see how that goes within my framework now :) neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Re: eval help

2003-03-03 Thread Dan Hardiker
Hi, > $arr2["name"] = "Broness!"; .. > $str3 = "Hello, $arr2['name']"; .. > eval ("\$evaldString = \"$str3\";"); > echo $evaldString; Your almost there... just remember one very simple rule - if in doubt, break out. Meaning, if you're having variable resolution issues, then just break out of the

[PHP] Re: eval help

2003-03-03 Thread neko
note that the following php: Hello, $name"; $str2 = "Hello, $arr[0]"; $str3 = "Hello, $arr2['name']"; eval ("\$evaldString = \"$str\";"); echo $evaldString; eval ("\$evaldString = \"$str2\";"); echo $evaldString; eval ("\$evaldString = \"$str3\";"); echo $evaldString; ?> produces: Broness!He