|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46601 E_RECOVERABLE_ERROR for "Call to a member function on a non-object"
Submitted: 2008-11-18 08:24 UTC Modified: 2014-10-07 22:10 UTC
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:0 (0.0%)
From: bugs dot php dot net-V29nHf1_z-nsp at cvogt dot org Assigned: thekid (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.6 OS:
Private report: No CVE-ID: None
 [2008-11-18 08:24 UTC] bugs dot php dot net-V29nHf1_z-nsp at cvogt dot org
Calling a method on a non-object results in a non catchable fatal error, that cannot be handled by an error_handler. It would be great if it would be a catchable fatal error instead. This would e.g. make possible to send an e-mail to the developers in case of such an error.

When using object-orientation heavily, a program bug can easily result in an uninitialized or wrongly initialized variable, currently leading to a fatal error. Being able to handle this error case would be a great improvement for quality control.

I hope the implementation of PHP allows such a change.

This request is similar to .

In case this request is rejected, please attach a short reason.

Reproduce code:
set_error_handler( create_function('$code','echo "error handler called ($code)\n";') );
$o = NULL;
echo "end of script\n";

Expected result:
error handler called (4096)
end of script

Actual result:
Fatal error: Call to a member function method() on a non-object


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-12 18:15 UTC] bugs dot php dot net dot nsp at cvogt dot org
There is a workaround for handling fatal errors:
 [2014-10-07 22:10 UTC]
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: thekid
 [2014-10-07 22:10 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

Fixed in PHP 7.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Oct 29 09:02:33 2020 UTC