Bug #12658 Updated: set_error_handler() not working properly (with 'Call to undefined function')

From: Date: Wed, 08 Aug 2001 19:48:54 +0000
Subject: Bug #12658 Updated: set_error_handler() not working properly (with 'Call to undefined function')
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-62623@lists.php.net to get a copy of this message
ID: 12658 Updated by: jmcastagnetto Reported By: joustin@plusnet.pl Old Status: Open Status: Feedback Bug Type: Scripting Engine problem Operating System: Red Hat Linux, Win2000 sp2 PHP Version: 4.0.6 Old Assigned To: Assigned To: jmcastagnetto New Comment: The assertion "... Seems that PHP cannot redirect 'Call to undefined function' errors to a custom error handler..." is incorrect. This seems to be a problem w/ the person reporting the bug *not* using the error_reporting() function, as it is clearly noted in the manual example, changing the code to read: <?php define (ERROR,E_USER_WARNING); define (WARNING,E_USER_NOTICE); // set the error reporting level for this script error_reporting (FATAL | ERROR | WARNING); // Define a simple error handler function error_handler ($level, $message, $file, $line, $context) { echo "An error of level $level was generated in file $file on line $line. \nThe error message was: $message \nThe following variables were set in the scope that the error occurred in: <blockquote> "; print_r ($context); print "\n</blockquote>"; } // Set the error handler to the error_handler() function set_error_handler ('error_handler'); trigger_error ("Some other error"); whatever(); ?> The output is: An error of level 1024 was generated in file bugtest.php on line 20. The error message was: Some other error The following variables were set in the scope that the error occurred in: <blockquote> Array ( [PWD] => /tmp [... snip ...] [_] => /usr/local/bin/php [PHP_SELF] => [argv] => Array ( [0] => bugtest.php ) [argc] => 1 [HTTP_POST_VARS] => Array ( ) [HTTP_GET_VARS] => Array [...snip...] </blockquote> This was tested with 4.0.6 on RH 7.1, more information is requested from the person reporting the bug, before it is reclassified as bogus. Previous Comments: ------------------------------------------------------------------------ [2001-08-08 13:23:32] joustin@plusnet.pl Seems that PHP cannot redirect 'Call to undefined function' errors to a custom error handler... A sample (taken partly from the manual): <pre> <?php // Define a simple error handler function error_handler ($level, $message, $file, $line, $context) { echo "An error of level $level was generated in file $file on line $line. \nThe error message was: $message \nThe following variables were set in the scope that the error occurred in: <blockquote> "; print_r ($context); print "\n</blockquote>"; } // Set the error handler to the error_handler() function set_error_handler ('error_handler'); trigger_error ("Some other error"); whatever(); // <- this will crash make the script die without calling the custom error_handler ?> ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=12658&edit=1

« previous php.dev (#62623) next »