check if variable empty

前端 未结 12 1300
旧时难觅i
旧时难觅i 2020-11-27 14:00
if ($user_id == NULL || $user_name == NULL || $user_logged == NULL) {
    $user_id = \'-1\';
    $user_name = NULL;
    $user_logged = NULL;
}
if ($user_admin == NUL         


        
12条回答
  •  -上瘾入骨i
    2020-11-27 14:20

    Felt compelled to answer this because of the other responses. Use empty() if you can because it covers more bases. Future you will thank me.

    For example you will have to do things like isset() && strlen() where instead you could use empty(). Think of it like this empty is like !isset($var) || $var==false

提交回复
热议问题