note 18611 added to function.get-object-vars

From: Date: Tue, 29 Jan 2002 15:02:28 +0000
Subject: note 18611 added to function.get-object-vars
Groups: php.notes 
Request: Send a blank email to php-notes+get-25969@lists.php.net to get a copy of this message
There is a strange behaviour, not sure whether it is a bug: if I call <? $single_object = $data_array_of_objects[0]; $array_of_objectvars = get_object_vars($single_object); foreach($array_of_objectvars as $key => $val) { echo(" $key => $val<br>"); } ?> I get only _ONE_ line with the $key = first variable name of the object and $val = the values of _ALL_ variables of the object including the first separated by a space. NOW: if I call <? $single_object = $data_array_of_objects[0]; $array_of_objectvars = get_object_vars($single_object); foreach($array_of_objectvars as $key => $val) { echo(" $key => $val<br>"); } echo($data_array_of_objects[0]->objectvar1."<br>"); echo($data_array_of_objects[0]->objectvar2."<br>"); ?> I get a list of $key = $ val as expected, before the other echos' are printed. It seems to me that get_object_vars works differently when you access a variable in those objects explicitly (as in the echos) -- http://www.php.net/manual/en/function.get-object-vars.php http://master.php.net/manage/user-notes.php?action=edit+18611 http://master.php.net/manage/user-notes.php?action=delete+18611 http://master.php.net/manage/user-notes.php?action=reject+18611

« previous php.notes (#25969) next »