Req #35269 [Opn->Csd]: Error handling: @ operator behavior / __autoload() and set_error_handler()
| From: | nikic@php.net | Date: | Fri, 28 Aug 2015 17:18:04 +0000 |
| Subject: | Req #35269 [Opn->Csd]: Error handling: @ operator behavior / __autoload() and set_error_handler() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195600@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=35269&edit=1
ID: 35269
Updated by: nikic@php.net
Reported by: thiago dot silva at kdemail dot net
Summary: Error handling: @ operator behavior / __autoload()
and set_error_handler()
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux/slackware
PHP Version: 5.0.5
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Parser errors are exceptions in PHP 7, so they will not be suppressed by @. Errors from __autoload
do use the error handler and always did: https://3v4l.org/ATkR9
Previous Comments:
------------------------------------------------------------------------
[2005-11-17 21:33:35] thiago dot silva at kdemail dot net
Description:
------------
The troublesome scenario:
Using a central __autoload() function to load all classes
of the application (wich uses libraries that uses
different file extensions):
function __autoload($classname) {
@include($classname.'.php');
if(class_exits($classname)) return;
@include($classname.'.class.php');
if(class_exits($classname)) return;
die("$classname not found");
}
Now, it is terrible to debug applications that use this
scheme. The @ operator supress fatal error messages. I
don't belive there is a point for this behavior. If one
doesn't want error messages, simply turn of the global
error_reporting option. Why expect a blank page for one or
two commands when something goes wrong?
Request #1: It would be desirable to have the @ operator
not supressing fatal error messages.
Now, in the __autoload() context, the user error handler
(setted with set_error_handler()) is not used, if we
remove the @ from include() statements. The warning
messages are sent to the default error handler (therefore,
to the output if display_errors is on).
Request #2: __autoload() should respect the current error
handler settings.
Related reports I've found:
#8294
#32545
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=35269&edit=1