empty

PHP 4, PHP 5, PHP 7, PHP 8
empty - Determine whether a variable is empty
Manual
Code Examples

empty( mixed$var ): bool

Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals false. empty does not generate a warning if the variable does not exist.

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 Values

Returns true if var does not exist or has a value that is empty or equal to zero, aka falsey, see conversion to boolean. Otherwise returns false.

Notes

Note:

Because this is a language construct and not a function, it cannot be called using variable functions, or named arguments.

Note:

When using empty on inaccessible object properties, the __isset() overloading method will be called, if declared.

Related Functions

Example of empty

Show all examples for empty

PHP Version:


Function empty:

Variable handling Functions

Most used PHP functions