简体   繁体   中英

PHP: List of all function Grouped by class

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM