入门——ci _remap的用法

来源:互联网 发布:妃子 侍寝 知乎 编辑:程序博客网 时间:2024/05/21 17:25

写在控制器里面,_remap的作用:就是你可以重新指向你想让他指向的方法


被重写的方法(通常是 URI 的第二段)将被作为参数传递到 remap() 方法:


public function _remap($method){if ($method === 'some_method'){$this->$method();}else{$this->default_method();}}


方法名之后的所有其他段将作为 remap() 方法的第二个参数,它是可选的。这个
参数可以使用 PHP 的 call user func array() 函数来模拟 CodeIgniter 的默认行为。


public function _remap($method, $params = array()){$method = 'process_'.$method;if (method_exists($this, $method)){return call_user_func_array(array($this, $method), $params);}show_404();}




0 0
原创粉丝点击