php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73892 Error handler example is kind of misleading
Submitted: 2017-01-09 02:05 UTC Modified: 2017-01-17 10:39 UTC
From: andre at webkr dot de Assigned: tpunt (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andre at webkr dot de
New email:
PHP Version: OS:

 

 [2017-01-09 02:05 UTC] andre at webkr dot de
Description:
------------
On manual page http://www.php.net/function.set-error-handler there is an example of an error handler and it contains this code:

    if (!(error_reporting() & $errno)) {
        // This error code is not included in error_reporting
        return;
    }

I think this gives the impression that this code emulates the behavior of the "normal" error handler: If the error is not included in the current error_reporting, do nothing.

However, there is a difference between this code and the case when no error handler is set at all. This code breaks error_get_last().

See https://3v4l.org/nvNsr

I suggest this code to be changed into

    if (!(error_reporting() & $errno)) {
        // This error code is not included in error_reporting
        return false;
    }

Because that would emulate the exact same behavior as when no error handler is set at all:

https://3v4l.org/cp5l0


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-12 00:08 UTC] cmb@php.net
-Package: Documentation problem +Package: Unknown/Other Function
 [2017-01-17 10:39 UTC] tpunt@php.net
Automatic comment from SVN on behalf of tpunt
Revision: http://svn.php.net/viewvc/?view=revision&revision=341674
Log: Resolve doc bug #73892
 [2017-01-17 10:39 UTC] tpunt@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: tpunt
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 19:01:35 2025 UTC