php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34761 error_reporting() interferes @ operator
Submitted: 2005-10-06 16:11 UTC Modified: 2005-10-06 16:15 UTC
From: tomas_matousek at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.1.0RC1 OS: WinXP
Private report: No CVE-ID: None
 [2005-10-06 16:11 UTC] tomas_matousek at hotmail dot com
Description:
------------
Setting a level of error reporting by a call to error_reporting(value) function interferes with @ operator, ie. if the value is >0 error messages are generated even within the scope of @ operator. This behavior contradicts a statement made by manual about @ operator:

"When prepended to an expression in PHP, any error messages that might be generated 
by that expression will be ignored." 

I would expect error messages to be ignored throughout an entire scope of the @ operator regardless of operations performed there.

The following example is quite artificial, however there may be situations one would like to have a function changing various configuration options including error reporting level. When he or she also wants to disable all warnings made by this function (or some of its caller) a problem arises.


Reproduce code:
---------------
<?
function f()
{
  var_dump(error_reporting(E_ALL));
  var_dump(error_reporting());
  array_fill(-1,-1,-1); // deliberately invalid arguments

@f();
var_dump(error_reporting());
?>

Expected result:
----------------
int(0)
int(0)
int(2047)

Actual result:
--------------
int(0)
int(2047)
Warning: array_fill(): Number of elements must be positive in ...
int(2047)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-06 16:16 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in CVS about a week ago. 
Try fresh snapshots before reporting.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 20:01:32 2024 UTC