#44821 [Opn]: Accessing NULL as an Array does not produce error
| From: | mcarpent at zenwerx dot com | Date: | Thu, 24 Apr 2008 16:50:49 +0000 |
| Subject: | #44821 [Opn]: Accessing NULL as an Array does not produce error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124483@lists.php.net to get a copy of this message | ||
ID: 44821
User updated by: mcarpent at zenwerx dot com
Reported By: mcarpent at zenwerx dot com
Status: Open
Bug Type: Arrays related
Operating System: Windows XP
PHP Version: 5.2.5
New Comment:
At least this is my understanding from the Array documentation which
states: Converting NULL to an array results in an empty array.
If this is the case and the NULL is converted to an empty array, should
PHP not display a notice for the undefined index.
Previous Comments:
------------------------------------------------------------------------
[2008-04-24 16:46:36] mcarpent at zenwerx dot com
Description:
------------
Accessing a null value as an array does not produce an error or even a
warning. It resolves to null and the script continues.
Reproduce code:
---------------
<?php
$foo = null;
echo "Foo: {$foo['bar']}";
$foo = array();
echo "Foo: {$foo['bar']}";
?>
Expected result:
----------------
Notice: Undefined index: bar in c:\test\test.php on line 4
Foo:
Notice: Undefined index: bar in c:\test\test.php on line 7
Foo:
Actual result:
--------------
Foo:
Notice: Undefined index: bar in c:\test\test.php on line 7
Foo:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44821&edit=1