PHP how to list out all public functions of class

后端 未结 4 1608
悲&欢浪女
悲&欢浪女 2020-12-30 02:32

I\'ve heard of get_class_methods() but is there a way in PHP to gather an array of all of the public methods from a particular class?

4条回答
  •  一整个雨季
    2020-12-30 03:16

    Yes you can, take a look at the reflection classes / methods.

    http://php.net/manual/en/book.reflection.php and http://www.php.net/manual/en/reflectionclass.getmethods.php

    $class = new ReflectionClass('Apple');
    $methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
    var_dump($methods);
    

提交回复
热议问题