PHP has different types of built-in functions which can be used to check the value of a variable. Basically there are three useful functions you can use for test the value of a variable i.e. isset(), empty() and is_null(). All these php function return a Boolean value.
isset() - It determine if a variable is set and is not NUL
empty() - It determine whether a variable is empty
is_null() - Finds whether a variable is NULL
Please check the below table for what these functions will return for different values. The blank spaces indicates that the function returns bool(false).
| Value of variable ($var) |
isset($var) |
empty($var) |
is_null($var) |
| (an empty string) |
bool(true) |
bool(true) |
|
| (space) |
bool(true) |
|
|
| FALSE |
bool(true) |
bool(true) |
|
| TRUE |
bool(true) |
|
|
| array() (an empty array) |
bool(true) |
bool(true) |
|
| NULL |
|
bool(true) |
bool(true) |
| 0 (0 as a string) |
bool(true) |
bool(true) |
|
| 0 (0 as an integer) |
bool(true) |
bool(true) |
|
| 0.0 (0 as a float) |
bool(true) |
bool(true) |
|
| var $var; (a variable declared, but without a value) |
|
bool(true) |
bool(true) |
| NULL byte (\ 0) |
bool(true) |
|
|
0 Comment(s)