2

Possible Duplicate:
print_r to get object methods in PHP?

How can I show what all the objects' methods and properties are?

That is, including the property's values?

Community
  • 1
  • 1

2 Answers2

5

See get_class_methods() and get_class_vars().

Also worth nothing that PHP's documentation is pretty good and generally a good place to ask first.

Edit: Of course, asking here seems to have its benefits as well. I never knew about the ReflectionClass Davide brought up :)

nnevala
  • 5,779
  • 2
  • 20
  • 13
5

To discover what the properties and the methods of an object are you can use ReflectionClass.

Davide Gualano
  • 12,813
  • 9
  • 44
  • 65
  • 1
    I think using Reflection to only get the class properties and methods is overkill. – NikiC Oct 20 '10 at 13:23
  • 1
    It depends on how many details you need: to just get the names of properties and methods get_class_methods() and get_class_cars() are fine, but if more informations are needed, like method parameters or access modifiers, Reflection is the way to go, imo. – Davide Gualano Oct 20 '10 at 14:30
  • You likely meant `ReflectionObject` – Gordon Oct 08 '12 at 11:29