RE: [PHP] how to trap eval error?

From: Date: Tue, 18 Nov 2003 20:42:41 +0000
Subject: RE: [PHP] how to trap eval error?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-170156@lists.php.net to get a copy of this message
Jay Blanchard wrote: > [snip] > eval('$return = $function($input);'); > [/snip] > > The problem is the quotes...the string is not truly being eval'd. Change > to double quotes > > eval("$return = $function($input);"); thanks for the tip but i am sure you mean: eval("\$return = \$function(\$input);"); otherwise the variables gets expanded before they get to eval and i end up with a syntax error. i found a solution (hopefully) with: if(function_exists($function)){ eval('$return = $function($input);'); }else{ // function does not exists } which works quit nicely for now. not sure if that's a good thing to do. thanks! david

« previous php.general (#170156) next »