Home > Article > Backend Development > How to determine whether a variable exists in php
Three ways for PHP to determine whether a variable exists:
1. bool isset (mixed var[,mixedvar [,mixed... ] )
Check whether the variable is set and it is not NULL.
If multiple parameters are passed in at one time, isset() will only return TRUE when all parameters are set. The calculation process is from left to right and will stop immediately when encountering an unset variable.
Related recommendations: "php tutorial"
2. bool empty (mixed $var)
Determine whether a variable is considered empty.
以下的东西被认为是空的: "" (空字符串) 0 (作为整数的0) 0.0 (作为浮点数的0) "0" (作为字符串的0) NULL FALSE array() (一个空数组) $var; (一个声明了,但是没有值的变量)
3. bool is_null (mixed $var)
The NULL type has only one value, which is the case-insensitive constant NULL.
The above is the detailed content of How to determine whether a variable exists in php. For more information, please follow other related articles on the PHP Chinese website!