thinkphp控制器调度使用示例 |
本文标签:thinkphp控制器,调度 1.如何通过地址栏参数来得到模块名称和控制器名称(即使在有路由和开了重写模块的情况下) 2.tp是如何实现前置,后置方法功能模块,和如何执行带参数的方法? php系统自带的 ReflectionClass,ReflectionMethod 类,可以反射用户自定义类的中属性,方法的权限和参数等信息,通过这些信息可以准确的控制方法的执行 ReflectionClass主要用的方法: ReflectionMethod 主要方法: 3.代码演示 复制代码 代码如下: <?php class IndexAction{ public function index(){ echo index."\r\n"; } public function test($year=2012,$month=2,$day=21){ echo $year.--------.$month.-----------.$day."\r\n"; } public function _before_index(){ echo __FUNCTION__."\r\n"; } public function _after_index(){ echo __FUNCTION__."\r\n"; } } //执行index方法 $method->invoke(new IndexAction); //执行后置方法
|