Why check both isset() and !empty()

后端 未结 10 2660
难免孤独
难免孤独 2020-11-21 23:48

Is there a difference between isset and !empty. If I do this double boolean check, is it correct this way or redundant? and is there a shorter way

10条回答
  •  轮回少年
    2020-11-22 00:17

    It is not necessary.

    No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false.

    php.net

提交回复
热议问题