Codeigniter 2:控制器误解与参考图法
问题描述:
public function _remap($method)
{
if ($method == 'some_method')
{
$this->$method();
}
else
{
$this->default_method();
}
}
这是我从官方网站上读到的。据我所知,_remap方法在所有操作之前都会被调用。但是这个指令$this->$method();
意味着调用$方法会再次调用_remap,它就像循环一样。不是吗?Codeigniter 2:控制器误解与参考图法
答
没有,_remap
由框架调用,初始化过程中,但是当你直接调用一些方法,你只能执行功能的内容...
希望是有帮助!
一些解释发现here:
Important: If your controller contains a function named _remap(), it will always get called regardless of what your URI contains. It overrides the normal behavior in which the URI determines which function is called, allowing you to define your own function routing rules.