how to trap eval error?

From: Date: Tue, 18 Nov 2003 20:18:50 +0000
Subject: how to trap eval error?
Groups: php.general 
Request: Send a blank email to php-general+get-170154@lists.php.net to get a copy of this message
Hi, i am new to this list as well as to PHP. i am in a situatin where i want to eval a string like: eval('$return = $function($input);'); where $function is a string specify a function to call and $input is the input parameter for the function. $return is just whatever is returned by the $function. my problem is that if $function is NOT defined anywhere, i got a fatal error like: Fatal error: Call to undefined function: ... <snip> does anyone who how to trap this error if it can be trap at all? what i have done so far is something similar to: set_error_handler('myHandler'); eval('$return = $function($input);'); that doesn't seem to work at all as 'myHandler' is never called. i have alose tried to check $php_errormsg but that doesn't seem to be helpful as well. as a last resort, i tried: error_reporting(E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE); set_error_handler('myHandler'); eval('$return = $function($input);'); that does seem to make the error stop appearing but my handler is still not called. any idea? thanks! david

« previous php.general (#170154) next »