1

I am looking for a way to get a list of all the php functions but needed them group by the class they exist in. Not sure if there is a way to get this from PHP docs or if its built into PHP. I am really only looking for built in / popular classes, so a custom mysqli class I dont care about but the mysql library that can be installed with PHP I do need.

Thank you very much

5
  • 4
    get_declared_classes() + ReflectionClass and a little bit of work will get you there... mysql is not a class though. Commented Apr 24, 2013 at 2:29
  • 1
    Look towards to Reflection, get_declared_functions, get_declared_classes, and software like PHPDocumentor Commented Apr 24, 2013 at 2:30
  • Many built-in and extension functions are not members of classes, but are prefixed like mysql_. those will be listed in groups via get_defined_functions(). Commented Apr 24, 2013 at 2:31
  • Haven't done any work in PHP myself, but from a quick view of the documentation it seems like get_class_methods might do what you want. Commented Apr 24, 2013 at 2:31
  • @deceze I meant mysqli Commented Apr 24, 2013 at 2:31

1 Answer 1

4

Try this:

foreach(get_declared_classes() as $classname) {
    echo $classname . PHP_EOL;
    $class = new ReflectionClass($classname);
    foreach($class->getMethods() as $m) {
        echo '  ' . $m->name . PHP_EOL;
    }
}

I'm using get_declared_classes() to get a list of all declared classes. Then I create a ReflectionClass object from them and iterate throught their methods.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.