PHP 4.0 Bug #8085: Referencing a non-existent array element inserts a key into the array
| From: | brichardson at lineone dot net | Date: | Sun, 03 Dec 2000 13:43:38 +0000 |
| Subject: | PHP 4.0 Bug #8085: Referencing a non-existent array element inserts a key into the array | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-39903@lists.php.net to get a copy of this message | ||
From: brichardson@lineone.net
Operating system: Linux
PHP version: 4.0.3pl1
PHP Bug Type: Arrays related
Bug description: Referencing a non-existent array element inserts a key into the array
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.
--
Edit Bug report at: http://bugs.php.net/?id=8085&edit=1