Bug #70550 [Opn->Nab]: Reference to undeclared array element, creates element
| From: | requinix@php.net | Date: | Tue, 22 Sep 2015 08:02:47 +0000 |
| Subject: | Bug #70550 [Opn->Nab]: Reference to undeclared array element, creates element | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196156@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70550&edit=1
ID: 70550
Updated by: requinix@php.net
Reported by: michal at econnect4u dot pl
Summary: Reference to undeclared array element, creates
element
-Status: Open
+Status: Not a bug
Type: Bug
-Package: PHP Language Specification
+Package: Scripting Engine problem
Operating System: Widnows
PHP Version: 5.6.13
Block user comment: N
Private report: N
New Comment:
null is not a pointer. PHP does not have pointers.
For a reference to exist, the thing it is a reference of must also exist. Trying to make a reference
to something that does not exist will therefore cause it to be created for you.
Previous Comments:
------------------------------------------------------------------------
[2015-09-22 07:15:35] michal at econnect4u dot pl
Description:
------------
Reference to undeclared array element, creates element, instead return null pointer.
Test script:
---------------
$array = array('a');
print_r($array);
$a= &$array[4];
print_r($array);
$array2 = array('b');
print_r($array2);
$a= $array2[4];
print_r($array2);
Expected result:
----------------
Array
(
[0] => a
)
Array
(
[0] => a
)
Actual result:
--------------
Array
(
[0] => a
)
Array
(
[0] => a
[4] =>
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70550&edit=1