views:

52

answers:

2

I have a class instance, and I want to enumerate its members.

How can this be done?

+1  A: 

You can use get_class_vars(), or get_object_vars() if you are looking at an instance.

You could also use reflection.

Tom Haigh
A: 

Take a look at PHP's reflection API

$r = new ReflectionClass("domdocument");
foreach ($r->getProperties() as $name => $prop) { ... }
foreach ($r->getMethods() as $name => $method) { ... }
johannes