get_class_methods

(PHP 4, PHP 5, PHP 7)

get_class_methods锟斤拷锟斤拷锟斤拷锟斤拷姆锟斤拷锟斤拷锟斤拷锟缴碉拷锟斤拷锟斤拷

说锟斤拷

get_class_methods ( mixed $class_name ) : array

锟斤拷锟斤拷锟斤拷锟斤拷姆锟斤拷锟斤拷锟斤拷锟缴碉拷锟斤拷锟介。

锟斤拷锟斤拷

class_name

锟斤拷锟斤拷锟斤拷锟竭讹拷锟斤拷实锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟斤拷 class_name 指锟斤拷锟斤拷锟斤拷锟叫讹拷锟斤拷姆锟斤拷锟斤拷锟斤拷锟斤拷锟缴碉拷锟斤拷锟介。锟斤拷锟斤拷锟斤拷锟斤拷蚍祷锟� NULL锟斤拷

锟斤拷锟斤拷

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);
    }
}

$class_methods get_class_methods('myclass');
// or
$class_methods get_class_methods(new myclass());

foreach (
$class_methods as $method_name) {
    echo 
"$method_name\n";
}

?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

myclass
myfunc1
myfunc2

锟轿硷拷

  • get_class() - 锟斤拷锟截讹拷锟斤拷锟斤拷锟斤拷锟�
  • get_class_vars() - 锟斤拷锟斤拷锟斤拷锟斤拷锟侥拷锟斤拷锟斤拷锟斤拷锟缴碉拷锟斤拷锟斤拷
  • get_object_vars() - 锟斤拷锟斤拷锟缴讹拷锟斤拷锟斤拷锟斤拷锟斤拷傻墓锟斤拷锟斤拷锟斤拷锟�