phanlcon initialize

基本上..能不用就不用 因為他的行為非常得奇怪..

phalcon是不能在controller裡面使用__construct的,所以他提供了幾個方案,其中一個是initialize

class MemberController extends BaseController
{
    public function initialize() //replace __construct
    {
     return $this->response->redirect('member/memberList');
   } 
/**會員列表 * */ 
    public function indexAction() 
    { 
      return $this->response->redirect('member/memberList'); 
    } 

    public function memberListAction() 
    { 
        echo "membelist"; exit;
    }
}//end class

各位觀眾 他的行為會變成這樣
1.執行 http://yourdomain/member/
他會執行 indexAction,無視initialize

2.執行 http://yourdomain/member/index
他會執行 indexAction,無視initialize

3.執行 http://yourdomain/member/memberlist
他會進入無窮迴圈,也就是說這個時候會呼叫initialize…

WTF…..

發佈留言