October 2005
Intermediate to advanced
372 pages
11h 35m
English
empty()
bool empty ( mixed var )The empty() function returns true if its parameter has a false value. This is not the same as the isset(): if a variable was set and had a false value (such as 0 or an empty string), empty() would return false, and isset() would return true.
$var1 = "0";
$var2 = "1";
$var3 = "";
if (empty($var1)) print "Var1 empty\n";
if (empty($var2)) print "Var2 empty\n";
if (empty($var3)) print "Var3 empty\n";
if (empty($var4)) print "Var4 empty\n";That would print "Var1 empty", "Var3 empty", then "Var4 empty".