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
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: 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 03:00:01 2026 UTC