Detailed introduction to the differences between is_null, empty, isset, and unset in php_PHP tutorial

WBOY
Release: 2016-07-21 15:11:17
Original
876 people have browsed it

is_null, empty, isset, unset Let’s take a look at the description of these four functions first.

isset determines whether the variable already exists (configuration)
unset deletes (releases) the variable
empty determines whether the variable is empty
is_null determines whether the variable is NULL
ok, people have already started . So to start, apart from unset, the other three of these four functions are judgment functions. Unset is the first to go out because it can't make mistakes. The second is is_null. We can think of it as !isset, which is an inverse operation of isset. , the following table can clearly illustrate the relationship between them:

Copy code The code is as follows:

Variables                                            empty is_null isset
$a=”” true
$a=null true true false
var $a true true false
$a=array() true false                true
$a= true false true
$a=0 true
$a="0" true
$ a="true"                                                                                                                                                                                                                                                                                                    a="true

From this we can find that as long as the variable is "" or 0, or false and null, empty will return true as long as these values ​​​​are, and isset determines whether the variable exists, as long as your variable is not null or not Assignment and return results are all true, and is_null is the opposite result of isset.

Of course, if you just want to do the following:
echo !isset($_GET['a']); //If you can’t get the value of variable a
echo empty($_GET['a'] ); //If the value of variable a is empty

Then the result is the same and can be used.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326913.htmlTechArticleis_null, empty, isset, unset Let’s take a look at the description of these four functions first. isset determines whether the variable already exists (configuration) unset deletes (releases) the variable empty determines whether the variable is...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!