note 83650 deleted from language.operators.comparison by danbrown

From: Date: Thu, 18 Jun 2009 14:03:54 +0000
Subject: note 83650 deleted from language.operators.comparison by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157062@lists.php.net to get a copy of this message
Note Submitter: Hayley Watson ---- @jescribens at urbangolem dot com <?php var_dump($x); //can be null if($x[0][0]['value'] < 1) ?> 'If the function returns null then you get "nok" printed.' Around here that sort of code would get you smacked. First, it's very unstable. Once fixed so that $something and $other had values, it would still print "nok" if $x[0][0]['value'] existed but contained the value zero, or indeed anything other than a number that's at least one. More importantly, if you want to check to see if something is null, wouldn't it be smarter (and certainly more self-explanatory) to check to see if it null instead of some random property that may or may not have anything to do with what you're wanting to check? <?php $x = myfunction(); if(is_null($x)) // or if($x===null) { echo 'nok'; } else { echo 'ok'; }

« previous php.notes (#157062) next »