TP6引入基类与TP5引入基类
TP5:
<?php namespace app\admin\controller; use think\Db; use think\facade\Session; use \think\Controller; class Index extends Controller { // Controller::__construct(); public function initialize(){ // __construct _initialize if(is_null(Session::get('users'))){ $this->redirect('User/login',302); // $this->success('需要登录哦', 'User/login'); } } }
TP6
<?php declare (strict_types = 1); namespace app\admin\controller; use think\facade\Session; use app\BaseController; class Index extends BaseController { public function __construct(){ // __construct _initialize if(is_null(Session::get('users'))){ $this->redirect('admin/User/login',302); // $this->success('需要登录哦', 'User/login'); } } }