php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75924 No doc: behavior of @ini_get('error_reporting') was changed from 5.6 to 7.0
Submitted: 2018-02-06 12:56 UTC Modified: 2018-02-06 13:36 UTC
From: mikko dot rantalainen at peda dot net Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 7.2.2 OS: Linux/Ubuntu
Private report: No CVE-ID: None
 [2018-02-06 12:56 UTC] mikko dot rantalainen at peda dot net
Description:
------------
---
From manual page: http://www.php.net/function.error-reporting
---

The ini_get('error_reporting') was historically the only way to get same results as current implementation of error_reporting(). However, the behavior
of ini_get('error_reporting') was changed between PHP 5.6 and 7.0 but this has not been documented anywhere.

See https://3v4l.org/3lFoe for demo.

Note that this also affect all custom error handlers that inspect value of ini_get('error_reporting') and not just @ini_get() syntax.

I assume that PHP 7.x ignores at-sign by design (the function name suggests that this is the value set in the ini file) but this change is missing official documentation.

I'd prefer this to be documented in both http://www.php.net/function.error-reporting and http://php.net/manual/en/function.ini-get.php

Test script:
---------------
<?php
# different results for PHP 5.x and 7.x:
ini_set('error_reporting', 1);
$a = array();
$a['ini_get'] = ini_get('error_reporting');
$a['error_reporting'] = error_reporting();
$a['@ini_get'] = @ini_get('error_reporting');
$a['@error_reporting'] = @error_reporting();
var_export($a);

Expected result:
----------------
The output should be stable for all versions.

Actual result:
--------------
Behavior is stable for 5.x and all versions of hhvm. However, PHP 7.x will ignore the at-sign (@) in front of ini_get(). I believe that PHP 4.x used to work identical to 5.x here but I do not have any environment to test that.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-06 13:36 UTC] requinix@php.net
-Summary: No doc: behavior of ini_get('error_reporting') was changed from 5.6 to 7.0 +Summary: No doc: behavior of @ini_get('error_reporting') was changed from 5.6 to 7.0 -Package: Documentation problem +Package: Scripting Engine problem
 [2018-02-06 13:36 UTC] requinix@php.net
The @ is not being ignored. Rather, (as I remember it) when @ suppresses error reporting it no longer affects the INI setting. ini_get() will properly report what the setting is, not the temporary value established during the expression evaluation. What I don't know/remember is whether this is tied to a bug report (couldn't find one) or one of 7.0's many other changes (AST?).

Since the behavior is from the @ I think noting the change is best suited for that doc page.
http://php.net/manual/en/language.operators.errorcontrol.php
 [2023-06-19 10:42 UTC] bloogersitelist at gmail dot com
Floor Decorate News are sharing latest news about about floor, decorate, design,estate etc. More info to visit: (https://floordecoratenews.com)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC