PHP's function to list all objects's properties and methods

Viewed 39095

Is there a function to list all object's public methods and properties in PHP similar to Python's dir()?

5 Answers

If you want to go deeper, and also get the private var of the object, you can use closure for that. like:

$sweetsThief = function ($obj) {
  return get_object_vars($obj);
};

$sweetsThief = \Closure::bind($sweetsThief, null, $myobj);

var_dump($sweetsThief($myobj));
Related