PHP如何列出类的所有公共功能 [英] PHP how to list out all public functions of class
本文介绍了PHP如何列出类的所有公共功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我听说过 get_class_methods()
,但是PHP中有没有办法从特定类中收集所有公共方法的数组?
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?
推荐答案
是的,可以看一下反射类/方法。
Yes you can, take a look at the reflection classes / methods.
http://php.net/manual/en/book.reflection.php 和
http://www.php.net/manual/en/reflectionclass.getmethods.php
$class = new ReflectionClass('Apple');
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
var_dump($methods);
这篇关于PHP如何列出类的所有公共功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文