tp3.2.3控制器继承有关问题-搞不懂

WBOY
Release: 2016-06-13 12:20:27
Original
1439 people have browsed it

tp3.2.3控制器继承问题-搞不懂
比如要登录验证,我以前用的时候TP3.1.2的版本,直接新建立一个conn控制器的类,然后用这个conn类继承action类,这个conn类用_initialize(){}  来实现验证设置,如果没有session则调整到login控制器来登录,其他需要验证的类就继承 ConnAction.class的类,但是在3.2.3这个版本我不知道怎么用了,就找到一个了前置控制方法 _before_index() 但是这个方法只能在单独一个控制器里面使用,怎么样全局都使用呢?
------解决思路----------------------
做一个判断登录与否的类 继承 Controller  其他方法再继承 你的这个类
然后有一个登录的页面 也是继承 Controller 

类似

<br />class BaseController extends Controller<br />{<br /><br />    public function _before_index()<br />    {<br />        if (session('?userid') == FALSE <br><font color='#FF8000'>------解决思路----------------------</font><br> session('?username') == FALSE) {<br />            $this->redirect('/index.php/Home/Login/index');<br />            exit;<br />        } else {<br />        }<br />       <br /><br />    }<br /><br />}<br /><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!