如何总结PHP查询类的方法?
- 内容介绍
- 文章标签
- 相关推荐
本文共计477个文字,预计阅读时间需要2分钟。
本教程操作环境:Windows 7系统、PHP 7.1版本、DELL G3电脑。在PHP中,可以使用get_class_methods()函数来查询类中存在哪些方法。
get_class_methods()函数可以获取类的所有方法,返回一个由方法名组成的数组。例如:
phpclass MyClass { public function method1() {} protected function method2() {} private function method3() {}}
methods=get_class_methods('MyClass');print_r($methods);
输出结果:
Array( [0]=> method1 [1]=> method2 [2]=> method3)
从输出结果可以看出,get_class_methods()函数返回了MyClass类的所有方法名,包括public、protected和private方法。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
在php中,可以使用get_class_methods()函数来查询类里面有哪些方法。
get_class_methods()函数可以获取类的所有方法,返回由类的方法名组成的数组。
本文共计477个文字,预计阅读时间需要2分钟。
本教程操作环境:Windows 7系统、PHP 7.1版本、DELL G3电脑。在PHP中,可以使用get_class_methods()函数来查询类中存在哪些方法。
get_class_methods()函数可以获取类的所有方法,返回一个由方法名组成的数组。例如:
phpclass MyClass { public function method1() {} protected function method2() {} private function method3() {}}
methods=get_class_methods('MyClass');print_r($methods);
输出结果:
Array( [0]=> method1 [1]=> method2 [2]=> method3)
从输出结果可以看出,get_class_methods()函数返回了MyClass类的所有方法名,包括public、protected和private方法。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
在php中,可以使用get_class_methods()函数来查询类里面有哪些方法。
get_class_methods()函数可以获取类的所有方法,返回由类的方法名组成的数组。

