Re: PHP5 CLI Custom Error Reporting Doesn't Work as Expected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Thus wrote Daniel Talsky:
>...
> 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.
>...

> 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;
>...
> 
> 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');

If you notice the warning, its complaining about a file not being
able to be opened, not that the required failed.  If you dont have
your errror_handler defined, php suppresses that warning because
it's futile to display since php is exiting anyway.


> 
> // FIRST TEST, PRINTS NOTHING
> // And also stops program execution even though I'm not doing anything.
> //foobar();

This is simply cause you can't capture a FATAL error.  The reason
why you can't catch these errors is because it is illegal to
execute anymore php code if php is exiting. 


Curt
-- 
Quoth the Raven, "Nevermore."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux