Posted By

ikimozu on 04/27/09


Tagged

null


Versions (?)

is_null


 / Published in: PHP
 

null -> true 0 -> false '0' -> false '' -> true

  1. <?php
  2. function is_null(&$var){
  3. if(!isset($var)){
  4. return true;
  5. }
  6. $var=(!is_array($var)) ? trim($var) : $var;
  7. if(gettype($var)=='string' && $var==='0'){
  8. return false;
  9. }else if(gettype($var)=='integer' && $var===0){
  10. return false;
  11. }else if(gettype($var)=='string' && $var===''){
  12. return true;
  13. }else if(gettype($var)=='NULL'){
  14. return true;
  15. }
  16. return false;
  17. }
  18. ?>

Report this snippet  

You need to login to post a comment.