php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #35269 Error handling: @ operator behavior / __autoload() and set_error_handler()
Submitted: 2005-11-17 21:33 UTC Modified: 2015-08-28 17:18 UTC
Votes:5
Avg. Score:2.6 ± 0.8
Reproduced:3 of 4 (75.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: thiago dot silva at kdemail dot net Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.5 OS: Linux/slackware
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: thiago dot silva at kdemail dot net
New email:
PHP Version: OS:

 

 [2005-11-17 21:33 UTC] 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 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-20 15:49 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2015-08-28 17:18 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2015-08-28 17:18 UTC] nikic@php.net
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
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 00:01:36 2025 UTC