Why check both isset() and !empty()

后端 未结 10 2509
难免孤独
难免孤独 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:29

    isset() tests if a variable is set and not null:

    http://us.php.net/manual/en/function.isset.php

    empty() can return true when the variable is set to certain values:

    http://us.php.net/manual/en/function.empty.php

    To demonstrate this, try the following code with $the_var unassigned, set to 0, and set to 1.

    
    

提交回复
热议问题