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

ThinkPHP5 quickly develops corporate sites
清雨
清雨 2017-09-26 09:22:57
0
2
1332
<?php
namespace app\admin\common;
use think\Controller;
use think\Session;

class Base extends Controller
{
    protected function _initializa()
    {
        parent::_initializa();
        //在公共控制器的初始化方法中,創(chuàng)建一個(gè)常量來判斷用戶是否登錄或已登錄
        define('USER_ID',Session::get('user_id'));
    }
    //判斷用戶是否登錄,在后臺(tái)
    protected function islogin()
    {
        //如果登錄常量為null,表示沒有登錄
        if (is_null('USER_ID')) {
            $this -> error('未登錄,無權(quán)訪問!','login/index');
        }
    }
    //如果用戶已經(jīng)登錄,將不允許再次登錄
    protected function alreadyLogin()
    {
        //如果登錄常量為null,表示沒有登錄
        if (!is_null(USER_ID)) {
            $this -> error('已經(jīng)登錄,不要重復(fù)登錄~~', 'index/index');
        }
    }

}

When accessing the background, it prompts the undefined constant USER_ID,

微信截圖_20170926092140.png

Logically speaking, it is in front define('USER_ID',Session::get('user_id')) ; The constant has already been defined. Why is this prompt

清雨
清雨

reply all(1)
清雨

Thank you everyone, the problem has been found

  • reply Dear, what is the problem and how to solve it. Solve
    phpcn1111 author 2018-02-02 10:45:43
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template