illustrate
1. Used to detect whether the variable is empty.
2. If the variable does not exist, or its value is equal to FALSE, it is considered not to exist. If there are no variables, empty() will not issue a warning.
grammar
bool empty (mixed $var)
Example
//empty() function checks whether a variable is empty public function check_empty(){ $a =''; var_dump(empty($a)); //Output true $b = null; var_dump(empty($b)); //output true $c =[]; var_dump(empty($c)); //output true var_dump(empty($d)); //Output true The variable is not assigned a value, output true $e = false; var_dump(empty($e)); //output true, $e=0 also outputs true false=0 if $e = true, outputs false $f = '0'; var_dump(empty($f)); //output true }
The above is the usage of php empty() function, I hope it will be helpful to everyone.