Re: eval help

From: Date: Mon, 03 Mar 2003 14:44:18 +0000
Subject: Re: eval help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-137894@lists.php.net to get a copy of this message
<?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 :(

« previous php.general (#137894) next »