php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60737 Note that set_exception_handler accepts NULL as parameter
Submitted: 2012-01-13 01:38 UTC Modified: 2012-01-14 06:03 UTC
From: four dot zerooneunauthorized at gmail dot com Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
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: four dot zerooneunauthorized at gmail dot com
New email:
PHP Version: OS:

 

 [2012-01-13 01:38 UTC] four dot zerooneunauthorized at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.set-exception-handler
---

It should be noted on this doc page that this 'set_exception_handler' function accepts NULL as the parameter (at least as of PHP 5.3.6).

Passing in NULL appears to remove the reference to the previous handler function, effectively resetting this feature to default state (nothing).

And, passing in NULL causes 'set_exception_handler' to return '(bool) true' rather than returning the previous handler function details as is currently documented.


Test script:
---------------
function testhandler1($errno= null, $errstr= null, $errfile= null, $errline = null)
{
	error_log(print_r(func_get_args(), true));
}

function testhandler2($errno= null, $errstr= null, $errfile= null, $errline = null)
{
	error_log(print_r(func_get_args(), true));
}

var_dump(set_exception_handler('testhandler1'));
var_dump(set_exception_handler('testhandler2'));
var_dump(set_exception_handler(null));

Actual result:
--------------
NULL
string(12) "testhandler1"
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-13 02:28 UTC] four dot zerooneunauthorized at gmail dot com
FYI - Relating to the return value of 'set_exception_handler', I opened change request https://bugs.php.net/bug.php?id=60737 to have the return value of this function changed to instead be the details (string or array) of the previous callback function as is currently documented instead of '(bool) true'.
 [2012-01-13 02:35 UTC] four dot zerooneunauthorized at gmail dot com
Sorry - wrong URL for my related change request for the return value of this 'set_exception_handler' function.  That should instead be https://bugs.php.net/bug.php?id=60738
 [2012-01-14 06:02 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=322259
Log: set_exception_handler accepts null to reset handler to default state. Closes bug #60737.
 [2012-01-14 06:03 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2012-01-14 06:03 UTC] frozenfire@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: Thu Oct 08 15:00:02 2026 UTC