2013-03-27 20 views
1
public function _remap($method) 
{ 
    if ($method == 'some_method') 
    { 
     $this->$method(); 
    } 
    else 
    { 
     $this->default_method(); 
    } 
} 

這是我從官方網站上讀到的。據我所知,_remap方法在所有操作之前都會被調用。但是這個指令$this->$method();意味着調用$方法會再次調用_remap,它就像循環一樣。不是嗎?Codeigniter 2:控制器誤解與參考圖法

回答

1

沒有,_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.