PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<class_existsget_class_vars>
Last updated: Mon, 16 Jul 2012

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

参见 get_class_vars()get_object_vars()




<class_existsget_class_vars>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST