使用关键点:
reflectionclass
class rbac extends my_controller{ public function index() { $arr = glob( __dir__ .directory_separator. '*.php');// $arr = glob(dirname(__dir__) . directory_separator . '*'); $mvc = array(); foreach ($arr as $path) { $basename = basename($path, '.php'); //仅支持合法的命名 if (preg_match('/^\w+$/', $basename) && $path != __file__) { require $path; $classname = ucfirst($basename); $ref = new reflectionclass($classname); foreach ($ref->getmethods() as $key => $methods) { var_dump( get_class_methods($methods)); if($methods->ispublic()){ $mvc[$methods->class][] = array( $methods->getname(), $methods->getfilename(), ); $methods->name; } } } } var_dump($mvc); }}