Home >Backend Development >PHP Tutorial >php empty()
This article mainly introduces the empty() function of PHP, which has a certain reference value. Now I share it with you. Friends in need can refer to it
empty() identifies "0" and 0 Or null($x)
That is, empty($x) == true is established
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 take effect: empty(trim($name)). As an alternative, trim($name) == false.
should be used when var exists and is a non-empty non-zero Returns FALSE if the value is a value, otherwise returns TRUE.
The following are considered empty:
"" (empty string)
0 (0 as an integer)
0.0 (0 as a floating point number) )
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
$var; (a variable declared but without a value)
Related recommendations:
The above is the detailed content of php empty(). For more information, please follow other related articles on the PHP Chinese website!