#35101 [Opn->Bgs]: A custom handler set with set_error_handler() cannot be unset/removed

From: Date: Sat, 11 Nov 2006 01:24:14 +0000
Subject: #35101 [Opn->Bgs]: A custom handler set with set_error_handler() cannot be unset/removed
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104811@lists.php.net to get a copy of this message
ID: 35101 Updated by: tony2001@php.net Reported By: mfischer@php.net -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: Any PHP Version: 6CVS New Comment: There is restore_error_handler() for that matter. Previous Comments: ------------------------------------------------------------------------ [2006-01-10 16:34:02] jon at fuck dot org well restore_error_handler() works in 5.1.1.. so what happened? code: <? function foo() { echo 'foo'; } set_error_handler('foo'); z; restore_error_handler(); f; ?> output: jon@ac-dev-sv1 ~ $ php -f foo.php foo Notice: Use of undefined constant f - assumed 'f' in /home/jon/foo.php on line 7 ------------------------------------------------------------------------ [2005-11-04 09:16:35] derick@php.net Nowhere it says that this is possible, thus marking it as a Feature Request. ------------------------------------------------------------------------ [2005-11-04 09:13:35] mfischer@php.net Description: ------------ A custom error handler set with set_error_handler() cannot be removed. The documentation says that the return value of set_error_handler() is the previous error handler. In case of no previous error handler, NULL is returned. However set_error_handler() cannot be called with NULL to restore the PHP default error handler. This results in the following: $ php -r 'set_error_handler(NULL);' Warning: set_error_handler() expects argument 1, '', to be a valid callback in Command line code on line 1 Reproduce code: --------------- <?php function handler() { echo "called\n"; } set_error_handler('handler called'); set_error_handler(); ?> Expected result: ---------------- Somehow a way for removing the current error handler and restoring the original behaviour should be possible. Actual result: -------------- handler called ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35101&edit=1

« previous php.bugs (#104811) next »