首页 > 网站 > WEB开发 > 正文

反射获取类名

2024-04-27 15:06:19
字体:
来源:转载
供稿:网友
<?/* Pass the name of the class, not a declared handler */function get_public_methods($className) {   /* Init the return array */   $returnArray = array();   /* Iterate through each method in the class */   foreach (get_class_methods($className) as$method) {       /* Get a reflection object for the class method */       $reflect = newReflectionMethod($className,$method);       /* For PRivate, use isPrivate().  For protected, use isProtected() */       /* See the Reflection API documentation for more definitions */       if($reflect->isPublic()) {           /* The method is one we're looking for, push it onto the return array */           array_push($returnArray,$method);       }   }   /* return the array to the caller */   return $returnArray;}?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表