CodeIgniter中Router类的两个方法

来源:互联网 发布:阿里云学校 编辑:程序博客网 时间:2024/04/29 23:03

File:

/* Location: ./system/core/Router.php */

第一个:

/** *  Fetch the current method * * @accesspublic * @returnstring */function fetch_method(){if ($this->method == $this->fetch_class()){return 'index';}return $this->method;}

第二个:

/** * Fetch the current class * * @accesspublic * @returnstring */function fetch_class(){return $this->class;}

第一个主要是获取当前请求的method,也就是controller下的action,

第二个主要是去当前访问的controller。

详情请看该类的代码。


因为这两个方法经常在做权限控制的时候需要用到,之前采用了如下的方式来取取得controller和method,不是很好。所以推荐使用上面的两个方法。

$this->CI->uri->segment(1)