如何获取Controller路径
比如有controller 为:classTest extends Controller
{
function Test() {
parent::Controller();
}
function hello($a,$b,$c){
....
}
}
如何能获取到hello的uri
仅仅为当前的hello的 test/hello/
而不是test/hello/a/b/c
即使传了参数$a,$b,$c,也只返回当前的test/hello/
uri_string()是不行的,
请指教. CI 应该没有这种方法,uri_string() 办不到的只能自己扩展了。
我想是应该在 router 里存储一些信息,因为所有控制器都是从 router 里进行分发的。然后在通过一个方法把刚才路由的结果返回给控制器(也许 router 类里就有这种方法,呵呵) $this->uri->rsegments会返回一个数组,其中就包括了控制名名和方法名 ls正解,rsegments包含index.php之后的全部seg 楼主只要控制器,参数不要,那个不好判断吧。 $this->uri->rsegments得到的就是控制器名,$this->uri->rsegments就是方法名 不一定吧,如果有目录呢?如果扩展了 router 有多级目录呢?呵呵 ->router->fetch_class()获得控制器名 楼上正解 支持楼上
页:
[1]
2