In PHP, empty means empty. It is a built-in function used to check whether a variable is empty. The syntax is "empty (mixed $var)"; when the variable does not exist or the value of the variable, etc. If used as false, the variable is judged to not exist and the empty() function will not generate a warning.
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
empty means empty. It is a built-in function in php that is used to check whether a variable is empty.
empty() determines whether a variable is considered empty. When a variable does not exist, or its value is equal to FALSE, then it is considered not to exist. empty() does not generate a warning if the variable does not exist.
Syntax
bool empty ( mixed $var )
Parameter description:
$var: Variable to be checked.
Note: Prior to PHP 5.5, empty() only supported variables; anything else would cause a parsing error. In other words, the following code will not work:
empty(trim($name))
Instead, you should use:
trim($name) == false
empty() without generating a warning, even if the variable does not exist. This means that empty() is essentially equivalent to !isset($var) || $var == false .
Return value
When var exists and is a non-empty and non-zero value, return FALSE otherwise return TRUE.
The following variables will be considered empty:
"" (empty string)
0 (as 0 as an integer)
0.0 (0 as a floating point number)
"0" (0 as a string)
NULL
The above is the detailed content of What does empty mean in php?. For more information, please follow other related articles on the PHP Chinese website!