Menu Samaritan's Purse

EMPTY

Determine whether a variable is empty

SYNTAX

empty ( mixed $var ) : bool

PARAMETERS

var

Variable to be checked

No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false.

RETURN

Returns FALSE if var exists and has a non-empty, non-zero value. Otherwise returns TRUE.

The following values are considered to be empty:

"" (an empty string)

0 (0 as an integer)

0.0 (0 as a float)

"0" (0 as a string)

NULL

FALSE

array() (an empty array)

EXAMPLES

1

1

2

1

3

1
1
1
1
1
1
1

4

bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true)

PHP