Date: 02/21/01
- Next message: CVS Account Request: "[PHP-DEV] CVS Account Request"
- Previous message: Chris Newbill: "RE: [PHP-DEV] Bug in date()?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: stevem <email protected>
Operating system: Red Hat Linux 6.2
PHP version: 4.0.4pl1
PHP Bug Type: PHP options/info functions
Bug description: set_error_handler() doesn't always catch errors
The files error_handler.inc, parse_error.php, and php_warning.php are included below.
We have error_handler.inc as the auto_prepend_file in php.ini. It defines an error handling function and then sets it. However, when a parse error occurs, our error handler is not called, as you can see in the following snippet of execution. It is clear that the error handler is not being called in the second case.
*******************************************
[httpd <email protected> php]$ php -q php_warning.php
ERROR HANDLER
[httpd <email protected> php]$ php -q parse_error.php
<br>
<b>Fatal error</b>: Call to undefined function: thisisjunk() in <b>parse_error.php</b> on line <b>3</b><br>
[httpd <email protected> php]$
*******************************************
error_handler.inc
==================================
<?
/*
>From php.ini:
E_ALL - All errors and warnings
E_ERROR - fatal run-time errors
E_WARNING - run-time warnings (non fatal errors)
E_PARSE - compile-time parse errors
E_NOTICE - run-time notices (these are warnings which often result from a bug in
your code, but it's possible that it was intentional (e.g., using an
uninitialized variable and relying on the fact it's automatically
initialized to an empty string)
E_CORE_ERROR - fatal errors that occur during PHP's initial startup
E_CORE_WARNING - warnings (non fatal errors) that occur during PHP's initial startup
E_COMPILE_ERROR - fatal compile-time errors
E_COMPILE_WARNING - compile-time warnings (non fatal errors)
*/
function myc_log_error($timeday, $message, $server, $level, $service, $script_name, $context) {
echo "ERROR HANDLER\n";
}
function myc_error_handler($errno, $errstr, $errfile, $errline, $context) {
switch($errno) {
case E_NOTICE:
case E_USER_NOTICE:
case 0: // this occurs when the statement was prepended with an @ symbol
// do nothing
break;
case E_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
case E_USER_WARNING:
myc_log_error(date("Y-m-d H:i:s"), $errstr, $GLOBALS['HOSTNAME'], $errno, $GLOBALS['SERVER_NAME'], $errfile, $context);
break;
default:
myc_log_error(date("Y-m-d H:i:s"), $errstr, $GLOBALS['HOSTNAME'], $errno, $GLOBALS['SERVER_NAME'], $errfile, $context);
header("Location: http://www.mycomputer.com/errors/error_available.html");
echo "Hello!\n";
exit();
break;
}
}
set_error_handler("myc_error_handler");
?>
==================================
php_warning.php
==================================
<?
foreach($arr as $hello) {
echo "$hello\n";
}
?>
===================================
parse_error.php
===================================
<?
thisisjunk();
?>
===================================
-- Edit Bug report at: http://bugs.php.net/?id=9386&edit=1-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: CVS Account Request: "[PHP-DEV] CVS Account Request"
- Previous message: Chris Newbill: "RE: [PHP-DEV] Bug in date()?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

