In PHP, the difference between isset (variable) and direct variable judgment is that when the variable is a null string, boolean value false, and numeric value 0, isset returns true for all, and directly returns false for all:
$ Empty = ''; echo (isset ($ empty )? '1': 0); // 1 echo'
'; Echo ($ empty? '1': 0); // 0
$ Empty = false; echo (isset ($ empty )? '1': 0); // 1 echo'
'; Echo ($ empty? '1': 0); // 0
$ Empty = 0; echo (isset ($ empty )? '1': 0); // 1 echo'
'; Echo ($ empty? '1': 0); // 0
They are the same only when the variables are null:
$ Empty = null; echo (isset ($ empty )? '1': 0); // 0 echo'
'; Echo ($ empty? '1': 0); // 0
Although isset does not have any function in judging variables, it is very useful in judging whether an array has one variable:
$ Arr = array ('1' => 1, '3' => 3); $ temp = null; // PS: arrays in php are different from those in map, if there is no key and you go to the value, it will lead to an error instead of returning null. Therefore, a corresponding judgment should be made first, and then the value if (isset ($ arr ['2']). {// The effect is equivalent to array_key_exists ('2', $ arr), but the code is shorter than $ temp = $ arr ['2'];} echo $ temp;
If you do not know about isset, you can go to the official website to see it:
Http://php.net/manual/zh/function.isset.php
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.