Codeigniter 获取当前的控制器名称和方法名称

在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

  1. Codeigniter get controller name in helper
  2. How to get Controller, Action, URL informations with CodeIgniter
相关文章
相关标签/搜索