2012-02-16 55 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文件