René wrote:
Hello,
My example:
$person->telnumber->value
$person->faxnumber->value
$person->???
The names of the objects "telnumber" and "faxnumber" (and further
possible subobjects) are not known for me.
How can I get the names of all subobjects of an object?
Thanks a lot.
René
If you use the function "get_class_vars", you can get a list of all the
properties of the class. Loop through each element of the resulting
array, and use the "is_object" function to determine if it's an object.
$class = new Classname();
$vars = get_class_vars($class);
while ( list($name, $val) = each($vars) ) {
if ( is_object($val) ) {
print $name . " is an object!\n";
// to reference the property directly - not sure in how
// many versions of PHP this works in
$subclass = $class->$name;
print_r($subclass);
print "\n";
}
}
Jason Dumler