Home >Backend Development >PHP Tutorial >PHP null value judgment

PHP null value judgment

WBOY
WBOYOriginal
2016-07-25 09:11:031184browse
Although empty and isset are both variable processing functions, they are both used to determine whether the variable has been configured, but they have certain differences: empty will also detect whether the variable is empty or zero. When a variable value is 0, empty considers the variable to be equal to empty, which is equivalent to not being set.
  1. /*For example, to detect the $id variable, when $id=0, use empty and isset to detect whether the variable $id has been configured. Both will return different values ​​- empty is considered not configured. , isset can get the value of $id: */
  2. $id=0;
  3. empty($id)?print "It's empty .":print "It's $id .";
  4. //Result: It's empty .
  5. print "
    ";
  6. !isset($id)?print "It's empty .":print "It's $id .";
  7. //Result: It's 0 .
  8. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn