Actually, I just realised that what I want to accomplish is different from
my example - the main issue is with scope:
<?php
/*
eval testing 3
SM 33/3/2003 2:32PM
*/
func1();
function func1()
{
echo("<br>we're in the pipe, 5-5-5.");
$str = "<br>Hello, \$name";
$str2 = "<br>Hello, \$arr[0]";
$str3 = "<br>Hello, \$arr2['name']";
echo doEvalWithVarsInScope($str);
echo doEvalWithVarsInScope($str2);
echo doEvalWithVarsInScope($str3);
}
function doEvalWithVarsInScope($str)
{
echo("<br>trying to eval for str=$str");
$name = "Scott";
$arr[] = "Dude";
$arr2["name"] = "Broness!";
eval ("\$evaldString = \"$str\";");
return $evaldString;
}
?>
--
will produce:
we're in the pipe, 5-5-5.
trying to eval for str=
Hello, $name
Hello, Scott
trying to eval for str=
Hello, $arr[0]
Hello, Dude
trying to eval for str=
Hello, $arr2['name']
Hello,
--
any (more) help is greatly appreciated.
cheers,
neko
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php