fork download
  1. <?php
  2.  
  3.  
  4. // empty
  5. echo "empty\n";
  6.  
  7. var_dump(empty($undefined));
  8.  
  9. $arr = array("", 0, 0.0, "0", NULL, FALSE, array());
  10. foreach($arr as $a)
  11.  
  12. echo "\n";
  13.  
  14. // empty_str
  15. echo "empty_str\n";
  16.  
  17. var_dump(empty_str($undefined));
  18.  
  19. $arr = array("", 0, 0.0, "0", NULL, FALSE, array());
  20. foreach($arr as $a)
  21. var_dump(empty_str($a));
  22.  
  23. echo "\n";
  24.  
  25. function empty_str(&$str)
  26. {
  27. return empty($str) && !(isset($str) && $str === "0");
  28. }
  29.  
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
empty
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

empty_str
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)
bool(true)
bool(true)