Edit report at https://bugs.php.net/bug.php?id=37676&edit=1
ID: 37676
Comment by: jason at fuzzystatic dot com
Reported by: tgross at m-s dot de
Summary: using Array access operator [] on boolean variable
does not show Notice
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
Bug still occurs on a 5.5-dev version.
example: http://codepad.viper-7.com/rn5kBm
Previous Comments:
------------------------------------------------------------------------
[2012-09-30 01:06:20] [email protected]
yeah, I remembered there was a similar bug report of this behavior, and I seems
made a fix for it.
if I remember correctlly, it was merged into master-branch already
------------------------------------------------------------------------
[2012-09-29 12:20:33] svodev at gmail dot com
The same issue is with NULL values;
$a = NULL;
echo $a['b'];
...and nothing happen
------------------------------------------------------------------------
[2006-06-02 11:25:00] [email protected]
Reclassified as feature request.
------------------------------------------------------------------------
[2006-06-02 11:21:51] tgross at m-s dot de
Description:
------------
When trying to access an array using an undefined offset, PHP displays an
Notice.
However, when you access a boolean variable with any combination of the array
operator [], PHP just returns NULL and displays no error message.
Reproduce code:
---------------
error_reporting (E_ALL);
$a = false;
var_dump ($a[5]);
var_dump ($a['test'][-3]);
Expected result:
----------------
PHP should display a Notice or a Warning.
Actual result:
--------------
PHP displays
NULL NULL
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=37676&edit=1