CodeIgniter: How to get Controller, Action, URL information

前端 未结 11 1242
死守一世寂寞
死守一世寂寞 2020-12-07 09:21

I have these URLs:

  • http://backend.domain.com/system/setting/edit/12
  • http://backend.domain.com/product/edit/1

How to get controller nam

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 10:11

    You could use the URI Class:

    $this->uri->segment(n); // n=1 for controller, n=2 for method, etc
    

    I've also been told that the following work, but am currently unable to test:

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

提交回复
热议问题