亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Create a public controller

We have created background verification, but we can still access it directly by directly entering the routing address. How should we solve this problem?

We use the __construct constructor, which can be called when the class is instantiated.

CommonController.class.php

<?php
namespace Admin\Controller;
use Think\Controller;
class CommonController extends Controller
{
    public function __construct(){
        parent::__construct();
        if (!Session('uid')){
            $this->error('請(qǐng)先登錄在訪問(wèn)',U('Login/index'));
        }
    }
}

We need to inherit this CommonController.class.php controller on each page

QQ截圖20170622154616.png

At this time When we directly access the route, it will prompt

QQ截圖20170621151016.png

#, so our public controller is completed.

Continuing Learning
||
<?php namespace Admin\Controller; use Think\Controller; class CommonController extends Controller { public function __construct(){ parent::__construct(); if (!Session('uid')){ $this->error('請(qǐng)先登錄在訪問(wèn)',U('Login/index')); } } }
submitReset Code