Req #39915 [Opn->Csd]: Trying to access the index of an integer should throw a warning
| From: | nikic@php.net | Date: | Wed, 10 Jul 2019 12:19:51 +0000 |
| Subject: | Req #39915 [Opn->Csd]: Trying to access the index of an integer should throw a warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-221680@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=39915&edit=1
ID: 39915
Updated by: nikic@php.net
Reported by: thuejk at gmail dot com
Summary: Trying to access the index of an integer should
throw a warning
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: *General Issues
Operating System: Linux
PHP Version: 5.2.0
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Will throw a notice in 7.4.
Previous Comments:
------------------------------------------------------------------------
[2015-01-09 00:41:33] ajf@php.net
Related: https://bugs.php.net/bug.php?id=37676
------------------------------------------------------------------------
[2006-12-20 23:31:49] thuejk at gmail dot com
Description:
------------
Trying to access the index of an integer is not a well-defined operation IMO, having no reasonable
meaning. In practice in PHP, it seems to simply return null in all cases.
I accidentally accessed an integer which I thought was a string. Because no error was returned it
took me some time to track down the problem.
Therefore, I suggest that trying to access an index on an integer should throw an E_NOTICE or
E_WARNING.
Reproduce code:
---------------
error_reporting(E_ALL | E_STRICT);
$a = 1234;
//This will print "", with no error raised.
echo '"'.$a[0].'"';
Expected result:
----------------
An E_NOTICE or E_WARNING.
Actual result:
--------------
No error raised
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=39915&edit=1