|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-06 14:31 UTC] johannes@php.net
-Status: Open
+Status: Feedback
[2010-04-06 14:31 UTC] johannes@php.net
[2010-04-06 15:07 UTC] fabien dot potencier at symfony-project dot org
[2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
Description: ------------ When throwing an exception from a custom error handler, PHP sometimes dies with a non-obvious error as the actual problem is hidden. To reproduce, create a simple set_error_handler() and throw an exception (ErrorException here) whenever an error occur (with error_reporting set to -1 for instance). If you try to output a not-defined variable, you will see the Exception. But, if you call a method on a not-defined variable, the exception is not thrown, and an error message is displayed instead. Debugging is not trivial as the real problem is masked. Test script: --------------- set_error_handler(function ($level, $message, $file, $line, $context) { throw new \ErrorException($message); }); // will throw an Exception (Undefined variable: foo) // echo $foo; // will not throw the exception, PHP will try to call bar() instead $foo->bar(); Expected result: ---------------- PHP Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: foo' in ..:.. Actual result: -------------- PHP Fatal error: Call to a member function bar() on a non-object in ... on line 0