By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

PHP Empty

Reference on the Empty Function of PHP. Including useful examples, and a list of things that are considered to be Empty.

Created: 2013-06-28 00:49

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';
}