$a =array (); $a = "; $a = "0"; $a =null; ...
if (empty ($a)) = = = if (! $a);
Recently see thinkphp Framework code, in the judgment statement, used a lot of empty () without!;
Ask: The framework writer is based on what purpose with empty () instead of!
Is it the empty ratio! Save server resources? Very confusing; I believe there must be a reason for asking why;
Reply to discussion (solution)
I think you made a mistake! The meaning of right and wrong.
if (empty ($a)) determines whether a $ A is empty, returns true for NULL, otherwise returns false
if (! $a) $a if there is a return of false, no returns True
! The logical operator is the inverse meaning.
Empty is the method.
The difference is that if $ A is not defined. Empty does not go wrong. and! $a will go wrong.
Var_dump (Empty ($a)); Var_dump (! $a); Will prompt notice:undefined variable:a