Home  >  Q&A  >  body text

Adding if(empty(USER_ID)) makes an error

protected function isLogin()

{

if(empty(USER_ID))

{

$this->error('User Not logged in, please log in',url('user/login'));

}

}


浮梦浮梦2571 days ago1924

reply all(3)I'll reply

  • ringa_lee

    ringa_lee2017-09-11 17:18:59

    What is the error message?

    reply
    0
  • 爱做梦的年纪

    爱做梦的年纪2017-09-09 07:45:42

    This is obviously not a variable. PHP loves $. You need to add $ to the variable. You need to assign a value to this variable. For example, $user_id = $_SESSION['USER_ID'].

    	 	if(empty(USER_ID))
    	 	{
    	 		$this->error('用户未登录,请登录',url('user/login'));
    	 	}

    I suggest you watch some introductory video tutorials. With some source code courseware, the improvement will be even greater: http://www.sucaihuo.com/video/143-0-0

    reply
    0
  • 爱做梦的年纪

    $user_id = $_SESSION['USER_ID']; if(empty($user_id)) { $this->error('The user is not logged in, please log in',url('user/login')); }

    爱做梦的年纪 · 2017-09-09 07:46:34
    初一

    USER_ID cannot be a constant

    初一 · 2017-09-13 16:05:33
    ringa_lee

    USER_ID can be constant

    ringa_lee · 2017-09-11 17:19:25
  • 按键盘手指磨破皮

    按键盘手指磨破皮2017-09-08 23:52:12

    You don’t send out the error message. You only have to guess when writing half of the code. What is USER_ID? Did you write it wrong? It's a variable and you didn't add $. Judging from your login, it should be a session, right? To write $_SESSION['USER_ID'];

    reply
    0
  • ringa_lee

    USER_ID can be a constant

    ringa_lee · 2017-09-11 17:19:45
  • Cancelreply