Re: how to trap eval error?

From: Date: Tue, 18 Nov 2003 21:55:50 +0000
Subject: Re: how to trap eval error?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-170182@lists.php.net to get a copy of this message
On Tue, Nov 18, 2003 at 02:03:25PM -0800, david wrote: : : Cpt John W. Holmes wrote: : : > From: "david" <dzhuo@looksmart.net> : >> : >> 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. : > : > Why not just do this: : > : > if(function_exists($function)) : > { $return = $function($input); } : > else : > { //function does not exist; } : : because i didn't know PHP can do that. thanks for the tip! any differences : between the 2 version in turns of performance and safety? You don't have to invoke eval()), and you don't have to worry about quoting issues in eval().

« previous php.general (#170182) next »