[PHP] Re: PHP5 CLI Custom Error Reporting Doesn't Work as Expected
by Daniel Schierbeck other posts by this author
Oct 24 2004 10:37AM messages near this date
Re: [PHP] PHP5 CLI Custom Error Reporting Doesn't Work as Expected
|
[PHP] Re: [PEAR-DEV] windows 98 support?
Daniel Talsky wrote:
> Included is my reproduce code.
>
> I'm trying to write a custom error logger for my PHP CLI script.
>
> The main problem is that when I try something like a failed require()
> statement, my custom error reporting function tells me it got an
> E_WARNING, but it stops program execution, which is not what the docs
> say it should do.
>
> When I try some other fatal error like trying to call an undefined
> function foobar(), then it doesn't run my custom error loggin function
> at all, just stops program execution.
>
> I tried to report this as a bug, and it was closed with no
> explanation...this is driving me to the brink of sanity. Can anyone
> help?
>
> #!/usr/local/bin/php -c /usr/local/etc/php.ini
> <?php
> function pv_shell_error_logger(
> $errno, $errstr, $errfile, $errline){
>
> switch ($errno){
>
> case E_ERROR:
> print('E_ERROR'."\n");
> break;
>
> case E_WARNING:
> print('E_WARNING'."\n");
> break;
>
> default:
> print('OTHER:'.$errno."\n");
> break;
>
> }
> return true;
> }
>
> error_reporting(0);
> // set to the user defined error handler
> set_error_handler("pv_shell_error_logger",
> (E_ALL));
>
> // FIRST TEST, PRINTS 'E_WARNING'
> // But also stops program execution even though I'm not doing anything.
> //require ('foo');
>
> // FIRST TEST, PRINTS NOTHING
> // And also stops program execution even though I'm not doing anything.
> //foobar();
>
> ?>
As far as I know the only errors you can handle through a user-defined
function are of levels E_USER_ERROR, E_USER_WARNING and E_USER_NOTICE.
php.net (http://dk2.php.net/manual/en/function.set-error-handler.php)
says this:
Note: The following error types cannot be handled with a user defined
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR, E_COMPILE_WARNING, and E_STRICT.
--
Daniel Schierbeck
Help spread Firefox (www.getfirefox.com):
http://www.spreadfirefox.com/?q=user/register&r=6584
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Daniel Talsky
Curt Zirzow
Daniel Schierbeck
|