empty
Determines whether a variable is empty. A variable is considered empty if it does not exist or if its value equals false.
Parameters
main.php
Return Values
bool
Returns true if var is empty, false otherwise
On success:true if variable is empty according to PHP's rules
On failure:false if variable has a non-empty value
Notes
- This is a language construct, not a function
- Empty values: null, false, 0, 0.0, '', '0', empty array, unset variables
- Does not generate warnings for undefined variables (unlike isset)
- For objects, calls __isset() magic method if available
Changelog
- 5.5.0: empty() now supports expressions, not just variables
Related Functions
isset
VariableDetermines if a variable is declared and is different than null.
checkvalidationsafety
strlen
StringReturns the length of a string in bytes.
lengthvalidationsecurity
is_array
VariableChecks whether a variable is an array.
validationtype-checksafety
preg_match
RegExPerforms a regular expression match against a string and returns whether a match was found.
regexpatternvalidation