700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > PHP_CodeIgniter _remap重新定义方法

PHP_CodeIgniter _remap重新定义方法

时间:2024-03-01 08:44:26

相关推荐

PHP_CodeIgniter _remap重新定义方法

如果controller定义了_remap方法, 在_remap中重新定义方法

class Test extends CI_Controller{public function index(){echo "hello world";}//index.php/Test/success/id/1aapublic function _remap($method,$params){if($method=='success'){$method .= '2'; return call_user_func_array(array($this, $method), $params);}else{$this->index();}}public function success2($id,$key){var_dump($id);var_dump($key);}}

上例中存在_remap方法, 重新定义success方法, 实现调用success2方法,

注意,不能直接访问方法success2,需要通过success来方法

手册上的说明

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。