<?php
/*
eval testing 3
SM 33/3/2003 2:32PM
*/
define("NAME_TAG", "name");
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_TAG."]";
echo doEvalWithVarsInScope($str);
echo doEvalWithVarsInScope($str2);
echo doEvalWithVarsInScope($str3);
}
function doEvalWithVarsInScope($str)
{
echo("<br>trying to eval for str=$str and NAME_TAG:".NAME_TAG);
$name = "Scott";
$arr[] = "Dude";
$arr2[NAME_TAG] = "Broness!";
eval ("\$evaldString = \"$str\";");
return $evaldString;
}
?>
--
produces:
we're in the pipe, 5-5-5.
trying to eval for str=
Hello, $name and NAME_TAG:name
Hello, Scott
trying to eval for str=
Hello, $arr[0] and NAME_TAG:name
Hello, Dude
trying to eval for str=
Hello, $arr2[name] and NAME_TAG:name
Hello, Broness!
--
done, but it's uglier than I was hoping :(
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php