PHP Empty
Reference on the Empty Function of PHP. Including useful examples, and a list of things that are considered to be Empty.
The Empty function of php, checks whether a variable is Empty or not.
The following is considered to be Empty.
| "" | An empty String |
| 0 | Zero declared as an Integer |
| 0 | Zero declared as a String |
| NULL | The constant NULL |
| FALSE | The keyword FALSE |
| var $MyVar; | Declared variables with no value. |
Example
Below is using a PHP If statement, to check if a variable was Empty.
if (empty($var)) {
echo '$MyVar is considered Empty';
}