From:             [EMAIL PROTECTED]
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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to