Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all the defined functions for an object

Is there an equivalent of get_defined_functions() which only shows the functions of a given object?

Example usage and output:

class A {
    function foo() { }
    function bar() { }
}
class B extends A {
    function foobar() { }
}
$b = new B();
print_r(get_object_functions($b));

// Array (
//  0 => "foo",
//  1 => "bar",
//  2 => "foobar"
//)
like image 287
nickf Avatar asked Dec 15 '08 05:12

nickf


2 Answers

Ah I found it:

get_class_methods()

like image 120
nickf Avatar answered Sep 20 '22 07:09

nickf


You could use ReflectionClass...

like image 35
Rob Avatar answered Sep 18 '22 07:09

Rob