get_class_methods()函数获取类方法的名称。它返回为name_of_class指定的类定义的方法名称的数组。如果发生错误,它将返回NULL。
get_class_methods(class)
name_of_class- 类名称。需要!
get_class_methods()函数返回为name_of_class指定的类定义的方法名称的数组。如果发生错误,它将返回NULL。
以下是一个例子-
<?php
class Demo {
function Demo() {
return(true);
}
function displayOne() {
return(true);
}
function displayTwo() {
return(true);
}
}
$method = get_class_methods('Demo');
$method = get_class_methods(new Demo());
foreach ($method as $method_name) {
echo "$method_name \n";
}
?>输出结果
Demo displayOne displayTwo