note 100241 deleted from language.types.null by danbrown

From: Date: Mon, 04 Oct 2010 15:06:24 +0000
Subject: note 100241 deleted from language.types.null by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172941@lists.php.net to get a copy of this message
Note Submitter: kdimi ---- The example of the previous poster and the results ARE as expected. Let me explain why. Here the example: <?php var_dump(0=='null'); var_dump(0==null); var_dump(null=='null'); ?> As different types are compared to each other, implicit typecasting is used here by PHP. So 0 == 'null' compares the number 0 with the string 'null' (this is _not_ NULL). String 'null' is no number, so it is converted to integer and becomes 0. The real comparison made here is 0 == 0 and the result TRUE. In 0==null the number 0 is compared to a constant named null. Again, this is _not_ NULL (because NULL is case sensitive!). The result here really depends on if the constant null is defined and it's value, the result can vary. In null=='null' a constant named null is compared to a string 'null'. The same as in the previous example applies. Conclusion: What the previous poster wrote, has nothing to do with the type NULL. The results shown have no relevance to this type.

« previous php.notes (#172941) next »