您现在的位置是:首页 > 其他

李清波 2017-04-01 其他 1798 复制当前网址

get_class_methods

get_class_methods


(PHP 4, PHP 5)


get_class_methods -- 返回由类的方法名组成的数组

描述


array get_class_methods ( mixed class_name )


 返回由 class_name 指定的类中定义的方法名所组成的数组。


注: 从 PHP 4.0.6 开始,可以指定对象本身来代替 class_name


例如:

$class_methods = get_class_methods($my_class); 
// see below the full example


例子 1. 

get_class_methods()


示例

<?php
class myclass {
    // constructor
    function myclass() {
        return(TRUE);
    }
    
    // method 1
    function myfunc1() {
        return(TRUE);
    }
    // method 2
    function myfunc2() {
        return(TRUE);
    }
}
$my_object = new myclass();
$class_methods = get_class_methods(get_class($my_object));
foreach ($class_methods as $method_name) {
    echo "$method_name\n";
}
?>


 运行结果:

myclass
myfunc1
myfunc2


文章来源:http://liqingbo.com/blog-1334.html

评论