Get all the defined functions for an object

10,464

Solution 1

Ah I found it:

get_class_methods()

Solution 2

You could use ReflectionClass...

Share:
10,464
nickf
Author by

nickf

Javascript nerd. Senior Software Engineer at Google. Ex-SoundClouder.

Updated on June 09, 2022

Comments

  • nickf
    nickf almost 2 years

    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"
    //)
    
  • Vlad the Impala
    Vlad the Impala almost 9 years
    NOTE: this will get instance methods too, not just class methods. I got confused by this.