2012-02-16 54 views
0

它爲什麼會給我這個錯誤,我檢查了所有的代碼,我希望沒有愚蠢的錯誤。登錄頁面是爲了顯示。CakePHP的博客教程 - 無法重新聲明UsersController :: beforeFilter()

致命錯誤:不能重新聲明用C UsersController :: beforeFilter():\ WAMP \ WWW \戴爾 - 博客\程序\控制器\ UsersController.php上線64

//line 63: 
    public function beforeFilter() { 
    parent::beforeFilter(); 
    $this->Auth->allow('add'); //Letting users register themselves 
    } 
+0

這意味着'不能重新聲明UsersController :: beforeFilter()'! – Rikesh 2012-02-16 09:38:16

回答

2

這意味着你已經宣佈public function beforeFilter()在同一個控制器中兩次。

+0

但教程告訴我做那件事 – Dale 2012-02-16 09:52:37

+0

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html – Dale 2012-02-16 09:56:08

+1

你可能誤解了它 – Shaheer 2012-02-16 10:26:38

0

我不熟悉cakephp,但我可以向你保證消息意味着上述函數(beforeFilter)先前已被聲明。搜索有問題的副本並將其刪除。

快樂結塊,歡呼聲

+0

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html – Dale 2012-02-16 09:56:16

+1

是的,我的朋友。我不必讀任何東西來告訴你我100%確定你的函數被聲明瞭兩次。錯誤消息已經足夠清晰,並適用於所有PHP代碼,不管是以Cake爲中心還是非以此爲中心。搜索'function beforeFilter',沒有可見性標識符(public)。確保您在整個應用程序代碼中進行搜索或「grep」,因爲它們可以輕鬆地位於不同的文件/包含中。祝你好運! – stefgosselin 2012-02-16 18:41:39

0

我有同樣的'錯誤'。這是因爲本教程告訴你,你必須編寫兩次,但必須明確的是,具有行是修改添加

public function beforeFilter(){ 
     $this->Auth->allow('index','view'); 
    } 

在AppController.php文件