|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64312 set_error_handler always return handler if called inside an error_handler
Submitted: 2013-02-27 15:43 UTC Modified: 2021-09-01 12:31 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: php at maisqi dot com Assigned:
Status: Analyzed Package: *General Issues
PHP Version: 5.4.12 OS: Win7 32 bits
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-02-27 15:43 UTC] php at maisqi dot com
If you set an error handler when inside an error handling function, set_error_handler will always return NULL.

Test script:

function first_handler () {
		echo "  first_handler\n";
		echo '     Set to second handler: <strong>', gettype (set_error_handler ('second_handler')), "</strong>\n";
		echo "\n\n", '$y = $o', "\n";
		$y = $o;
function second_handler () {
		echo "  second_handler\n";

set_error_handler ('first_handler');
echo '$x = $y', "\n";
$x = $y;
echo '     Set to other handler: <strong>', gettype (set_error_handler (function(){})), "</strong>\n";

Expected result:
set_error_handler should return the name of the error handling function, which in this case would be the name of the running function.

Actual result:
It just returns null.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-27 15:45 UTC] php at maisqi dot com
Test script:
 [2013-02-28 02:41 UTC]
before calling to user error handler,  PHP will set empty to 
EG(uesr_error_handler) in case of recursivly call to error handler if there is 
some error in the error_handler function self.

IMO this is a trivial bug, if we want to to fix this, maybe add a new 
 [2013-02-28 02:42 UTC]
-Status: Open +Status: Analyzed
 [2016-02-17 12:42 UTC] php at maisqi dot com
This is old, and I think it can be considered as acceptable behaviour. I therefore suggest to convert this bug into a documentation issue. I think the documentation should describe what happens when there's an error or warning inside a error handler, unless set_error_handler() inside it.
 [2021-09-01 12:31 UTC]
-Type: Bug +Type: Documentation Problem
 [2021-09-01 12:31 UTC]
> I therefore suggest to convert this bug into a documentation issue.

 [2024-06-22 07:12 UTC] Steven268Danner at outlook dot com
Thank you for sharing such an informative post with us. (
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 11:01:30 2024 UTC