Home >Backend Development >PHP Tutorial >5 ways to determine whether an array is empty in PHP

5 ways to determine whether an array is empty in PHP

巴扎黑
巴扎黑Original
2016-11-11 09:45:47971browse

In PHP, "NULL" and "empty" are two concepts.
isset is mainly used to determine whether a variable has been initialized.
empty can judge variables with values ​​of "false", "empty", "0", "NULL" and "uninitialized" as TRUE.
is_null can only judge variables with values ​​of " NULL" variables are judged as TRUE
var == null Variables with values ​​​​"false", "empty", "0", and "NULL" are all judged as TRUE
var === null Only variables with values ​​​​are "NULL" The variable is judged to be TRUE
Note: When judging whether a variable is really "NULL", is_null is mostly used to avoid interference from "false", "0" and other values.

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