[PHP] 获取某个类的公有方法、私有方法 →→→→→进入此内容的聊天室

来自 , 2019-02-11, 写在 PHP, 查看 161 次.
URL http://www.code666.cn/view/77edbe5f
  1. function getClassMethods($class,$type = 'all') {
  2.  
  3.     $typeArr = array('public','protected','private','static','final','abstract');
  4.     $type = !in_array(strtolower($type),$typeArr) ? 'all' : 'is'.$type;
  5.     $methods = array();
  6.     $reflection  = new ReflectionClass($class);
  7.     foreach($reflection ->getMethods() as $obj){
  8.         if('all' == $type) {
  9.             $methods[] = $obj->name;
  10.         }else {
  11.             if(call_user_func(array(new ReflectionMethod($obj->class, $obj->name),$type))){
  12.                 $methods[] = $obj->name;
  13.             }
  14.         }
  15.     }
  16.     return $methods;
  17. }

回复 "获取某个类的公有方法、私有方法"

这儿你可以回复上面这条便签

captcha