PHP has many similar functions, but there are slight differences...
Is_null, empty, isset, and unset. Let's take a look at the descriptions of these four functions.
Isset determines whether a variable already exists (configuration)
Unset: delete (release) the variable.
Empty determines whether the variable is null
Is_null determines whether the variable is NULL
OK. You have started to engage. In the beginning, except for unset, all the other three functions are judgment functions. unset first goes out, because it will not be wrong, followed by is_null. we can regard it! Isset is an inverse operation of isset. The following table clearly describes the relationship between them:
Empty is_null isset
$ A = "true false true
$ A = null true false
Var $ a true false
$ A = array () true false true
$ A = false true
$ A = 15 false true
$ A = 1 false true
$ A = 0 true false true
$ A = "0" true false true
$ A = "true" false true
$ A = "false true
From this, we can find that as long as the variable is "" or 0, or false or null, empty will return true, and isset is to determine whether the variable exists, as long as this variable is not null or not assigned a value, the returned result is true, and is_null is exactly the reverse result of isset.