在我的Cake
PHP 2应用程序中,我遇到了beforeFilter的问题.
在 this thread它运作良好.因为CakePHP的旧版本.
在 this thread它运作良好.因为CakePHP的旧版本.
在我的代码中,如果用户未获得授权,我想向他显示“anotherview.ctp”.
我不想将访问者重定向到另一个页面. (因为adsense问题)
当我在beforeFilter中使用“this-> render”时,我的“index”操作中的代码也会运行.
我想在“beforeFilter”的最后一行之后停止执行.
当我将“exit()”添加到beforeFilter时,它破坏了我的代码.
如何在不破坏代码的情况下在beforeFilter中停止执行?
class MyController extends AppController { function beforeFilter() { if ( $authorization == false ) { $this->render('anotherview'); //exit(); } } } function index() { // show authorized staff } }
尝试:
$this->response->send(); $this->_stop();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。