PHP 4.0 Bug #8085 Updated: Referencing a non-existent array element inserts a key into the array
| From: | stas@php.net | Date: | Sun, 03 Dec 2000 13:52:16 +0000 |
| Subject: | PHP 4.0 Bug #8085 Updated: Referencing a non-existent array element inserts a key into the array | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-39906@lists.php.net to get a copy of this message | ||
ID: 8085
Updated by: stas
Reported By: brichardson@lineone.net
Status: Closed
Bug Type: Arrays related
Assigned To:
Comments:
It should work this way. TO reference a variable, it should
exist. So, the latter code actually does produce two
variables, $undefined and $not_there, both havng NULL value.
Previous Comments:
---------------------------------------------------------------------------
[2000-12-03 08:43:38] brichardson@lineone.net
This caught me out:
unset($tarray);
unset($undefined);
$tarray["one"] = 1;
$undefined =& $tarray["two"];
while (list($key, $value) = each($tarray)) {
echo $key . "|" . $value . "<br>";
}
That code will generate this output:
one|1
two|
So you can see that the 4th line of the code creates a key "two" in the
array with an unset value.
I don't think it should do that. After all, this code:
unset($undefined);
unset($not_there);
$undefined =& $not_there;
generates precisely nothing.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=8085