#40959 [Opn->Bgs]: Returning unset array key by reference sets it to null
| From: | mike@php.net | Date: | Fri, 30 Mar 2007 14:50:30 +0000 |
| Subject: | #40959 [Opn->Bgs]: Returning unset array key by reference sets it to null | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-110963@lists.php.net to get a copy of this message | ||
ID: 40959
Updated by: mike@php.net
Reported By: mamay55 at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Linux/Windows
PHP Version: 5.2.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
Previous Comments:
------------------------------------------------------------------------
[2007-03-30 14:41:46] mamay55 at gmail dot com
Description:
------------
Whenever a function (global or class method) returns a reference to an
array element which is not set, the value of that element is set to
null.
Reproduce code:
---------------
$data = array();
function &get_data($key) {
global $data;
return $data[$key];
}
print_r($data);
$result = &get_data('TEST');
echo $result;
print_r($data);
Expected result:
----------------
The expected result would be that the value of the unset element would
not be set and the following warning would be produced:
Undefined index: TEST in ...
Actual result:
--------------
Array
(
)
Array
(
[TEST] =>
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40959&edit=1