PHP5 CLI Custom Error Reporting Doesn't Work as Expected

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

 



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();

?>

-- 
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