When the variable is an empty string and a Boolean value of false and the value 0 o'clock, isset all returns True, directly judging all return false:
$empty='';echo (isset($empty)?'1':0);//1echo'
';echo ($empty?'1':0);//0
$empty=false;echo (isset($empty)?'1':0);//1echo'
';echo ($empty?'1':0);//0
$empty=0;echo (isset($empty)?'1':0);//1echo'
';echo ($empty?'1':0);//0
They are indistinguishable only when the variables are null:
$empty=null;echo (isset($empty)?'1':0);//0echo'
';echo ($empty?'1':0);//0
Although Isset does not work in judging variables, it is useful to have a variable in the judgment array:
$arr=array('1'=>1,'3'=>3);$temp=null;//PS:php中数组不同于map,如果没有key而你去取值会引发错误而不是返回null,所以要有对应的判断,先判断再取值if (isset($arr['2'])) {//效果等同于array_key_exists('2', $arr),但相对代码短一点$temp=$arr['2'];}echo$temp;
And the isset do not know can go to the official website to see the understanding:
http://php.net/manual/zh/function.isset.php
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the PHP isset variable and the difference between the direct judgment variable, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.