CodeIgniter中Router类的两个方法

file:php

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

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

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

	return $this->method;
}

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

/**
 * Fetch the current class
 *
 * @access	public
 * @return	string
 */
function fetch_class()
{
	return $this->class;
}

详情请看该类的代码。code

 

由于这两个方法常常在作权限控制的时候须要用到,以前采用了以下的方式来取取得controller和method,不是很好。因此推荐使用上面的两个方法。权限控制

$this->CI->uri->segment(1);
相关文章
相关标签/搜索