The difference and connection between empty and isset PHP is a weak type language. it is different from C #/JAVA. when declaring a variable, you do not need to declare its type. therefore, there may be many special values and occasionally some strange problems.
In the afternoon, I stole a truth table from a foreign website. it was very intuitive and detailed ~ Send it quickly.
Differences and relationships between empty and isset
To talk about their connection, empty () and isset () are both variable processing functions. they are used to determine whether the variables have been configured, it is because of their great similarity in the process of processing variables that they lack understanding of their relationships. Considering the functions empty () and isset (), we will confuse people and give them a different angle. The processing objects of empty () and isset () are almost undefined variables, 0, empty strings.
If the variable is 0, empty () returns TRUE, and isset () returns TRUE;
If the variable is a null string, empty () returns TRUE, and isset () returns TRUE;
If the variable is not defined, empty () returns TRUE, and isset () returns FLASE;
Empty () is described as follows:
Description: bool empty (mixed var)
If var is a non-null or non-zero value, empty () returns FALSE. In other words, "", 0, "0", NULL, FALSE, array (), var $ var; and objects without any attributes will be considered empty, if var is null, TRUE is returned.
Isset () is described as follows:
Isset () check whether the variable is set
Description: bool isset (mixed var [, mixed var [,...])
If var exists, TRUE is returned; otherwise, FALSE is returned.
If unset () is used to release a variable, it will no longer be isset (). If you use isset () to test a variable that is set to NULL, FALSE is returned. Note that a NULL byte ("\ 0") is not equivalent to the NULL constant of PHP.
Warning: isset () can only be used for variables, because passing any other parameter will cause a parsing error. To check whether a constant has been set, use the defined () function.
You can use the isset function to determine whether a variable has been declared.
You can use the empty function to determine whether a variable has been assigned data and is not empty.
To determine whether a variable exists and is not empty, use the isset function and the empty function.