Home  >  Article  >  Backend Development  >  php empty()

php empty()

不言
不言Original
2018-04-26 09:04:163785browse

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:

Some basic syntax of php

The above is the detailed content of php empty(). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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