Re: how to trap eval error?
| From: | david | Date: | Tue, 18 Nov 2003 22:03:25 +0000 |
| Subject: | Re: how to trap eval error? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170178@lists.php.net to get a copy of this message | ||
Cpt John W. Holmes wrote:
> From: "david" <dzhuo@looksmart.net>
>
>
>> 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.
>
> 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?
david