I have a class instance, and I want to enumerate its members.
How can this be done?
I have a class instance, and I want to enumerate its members.
How can this be done?
You can use get_class_vars()
, or get_object_vars()
if you are looking at an instance.
You could also use reflection.
Take a look at PHP's reflection API
$r = new ReflectionClass("domdocument");
foreach ($r->getProperties() as $name => $prop) { ... }
foreach ($r->getMethods() as $name => $method) { ... }