Codeigniter get controller name in helper

后端 未结 4 605
醉酒成梦
醉酒成梦 2021-02-08 04:13

I have a custom helper that i use for logging.

Within one of the functions of the helper i need to get the name of the controller that was called. Is there a way to do i

4条回答
  •  长情又很酷
    2021-02-08 04:58

    this should work (not so sure if it works in the helper):

    $ci =& get_instance();
    $ci->router->class // gets class name (controller)
    $ci->router->method // gets function name (controller function)
    

提交回复
热议问题