在Codeigniter 可以通过下面两个方法获取当前的控制器名称和方法名称

$this->router->fetch_class();
$this->router->fetch_method();

在Codeigniter 3.1.x版本中,可使用

$this->router->class;
$this->router->method;

通过system/core/Router.php 文件源码中 的67到79行 块注释可以看到, $class属性是当前的类名,$method属性是当前的方法名。

参考:

  1. Codeigniter get controller name in helper
  2. How to get Controller, Action, URL informations with CodeIgniter

相关文章:

  • 2022-02-24
  • 2021-08-13
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2022-02-15
猜你喜欢
  • 2021-08-29
  • 2021-04-06
  • 2022-02-01
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
相关资源
相似解决方案