Kohana 3 get current controller/action/arguments

前端 未结 3 1977
悲&欢浪女
悲&欢浪女 2021-02-02 13:18

In Kohana 2 you could easily get that information like this:

echo router::$controller;
echo router::$method;
echo router::$arguments[0-x];

Any

3条回答
  •  广开言路
    2021-02-02 14:02

    Updated answer for Kohana 3.2, from the user guide:

    // From within a controller:
    $this->request->action();
    $this->request->controller();
    $this->request->directory();
    
    // Can be used anywhere:
    Request::current()->action();
    Request::current()->controller();
    Request::current()->directory();
    

提交回复
热议问题