php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68293 bad example
Submitted: 2014-10-23 20:28 UTC Modified: 2014-11-22 19:05 UTC
From: rasmus at mindplay dot dk Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4.34 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rasmus at mindplay dot dk
New email:
PHP Version: OS:

 

 [2014-10-23 20:28 UTC] rasmus at mindplay dot dk
Description:
------------
---
From manual page: http://www.php.net/class.errorexception
---

The example quoted in the documentation will break the @ error suppression operator - it won't work, and also doesn't respect the error_reporting() setting, which needs to be checked either way to make sure the @ operator works as expected.

See below for a working example.


Test script:
---------------
function exception_error_handler($errno, $errstr, $errfile, $errline) {
    $error = new ErrorException($errstr, 0, $errno, $errfile, $errline);

    if ($error->getSeverity() & error_reporting()) {
        throw $error;
    }
}

Expected result:
----------------
See above.

Actual result:
--------------
See above

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-19 16:49 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=335199
Log: respect error_reporting level in ErrorException example (doc bug #68293)
 [2014-11-22 19:05 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2014-11-22 19:05 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 11:00:02 2026 UTC