Bug #14152: foreach() can create objects with blank property names

From: Date: Tue, 20 Nov 2001 18:22:53 +0000
Subject: Bug #14152: foreach() can create objects with blank property names
Groups: php.dev 
Request: Send a blank email to php-dev+get-71112@lists.php.net to get a copy of this message
From: basil.hussain@kodakweddings.com Operating system: Linux 2.2.16-enterprise PHP version: 4.0.5 PHP Bug Type: Class/Object related Bug description: foreach() can create objects with blank property names Using the following code (which someone may do accidentally): $myarray = array("X" => "A", "Y" => "B", "Z" => "C"); foreach($myarray as $key->$value) { ... } causes PHP (on each iteration) to create an object $key with the value of the current array element in a property with a blank name (because $value has just been created, and is therefore empty). The following var_dump() output illustrates: object(stdClass)(1) { [""]=> string(1) "A" } The creation of objects with blank property names seems like it shouldn't be possible (even unintentionally)! -- Edit bug report at: http://bugs.php.net/?id=14152&edit=1

« previous php.dev (#71112) next »