在Codeigniter 能够经过下面两个方法获取当前的控制器名称和方法名称php
$this->router->fetch_class(); $this->router->fetch_method();
在Codeigniter 3.1.x版本中,可以使用fetch
$this->router->class; $this->router->method;
经过system/core/Router.php
文件源码中 的67到79行 块注释能够看到, $class
属性是当前的类名,$method
属性是当前的方法名。this
参考:code