|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35963 first call to set_error_handler returns same value on success and error
Submitted: 2006-01-10 16:35 UTC Modified: -
Avg. Score:4.1 ± 0.6
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:3 (42.9%)
From: jon at fuck dot org Assigned:
Status: Open Package: Feature/Change Request
PHP Version: 5.1.1 OS: gnu/linux, 2.6.14-1.1637_FC4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
38 + 5 = ?
Subscribe to this entry?

 [2006-01-10 16:35 UTC] jon at fuck dot org
the first call to set_error_handler returns NULL on success. on failure, e.g., if the desired callback function has not been declared, an E_WARNING is thrown and NULL is returned. this makes checking for failure of this function a little kludgy.

it would be better to always return FALSE on error, or, return the name of the internal PHP error handler on success, which is what our custom error handlers will be replacing on the first call.

by looking at previous bugs about this, it seems as though the documentation was right and the code was wrong.

Reproduce code:
function foo() { echo 'foo'; }
echo (NULL === set_error_handler('foo'));
echo (NULL === set_error_handler('bar'));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 25 14:03:45 2021 UTC