note 100241 added to language.types.null

From: Date: Mon, 04 Oct 2010 03:10:40 +0000
Subject: note 100241 added to language.types.null
Groups: php.notes 
Request: Send a blank email to php-notes+get-172922@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 93.195.87.43 ---- Manual Page -- http://www.php.net/manual/en/language.types.null.php Edit -- https://master.php.net/note/edit/100241 Del: integrated -- https://master.php.net/note/delete/100241/integrated Del: useless -- https://master.php.net/note/delete/100241/useless Del: bad code -- https://master.php.net/note/delete/100241/bad+code Del: spam -- https://master.php.net/note/delete/100241/spam Del: non-english -- https://master.php.net/note/delete/100241/non-english Del: in docs -- https://master.php.net/note/delete/100241/in+docs Del: other reasons-- https://master.php.net/note/delete/100241 Reject -- https://master.php.net/note/reject/100241 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172922) next »