note 104785 added to control-structures.if

From: Date: Thu, 07 Jul 2011 09:21:50 +0000
Subject: note 104785 added to control-structures.if
Groups: php.notes 
Request: Send a blank email to php-notes+get-181307@lists.php.net to get a copy of this message
PHP compares numbers inside quotations, in an interesting way. This can create confusions to those who did not refer this manual, but expected something different. <?php define('NUMBER', 13); $number = NUMBER; if('13_2' == NUMBER) { echo('Why matched?'); }; if('13_2' == "{$number}") { echo('Why not matched?'); } ?> In the above example, the first comparison matches; that you don't expect. The second comparison does not match. ---- Server IP: 69.147.83.197 Probable Submitter: 117.121.234.131 ---- Manual Page -- http://www.php.net/manual/en/control-structures.if.php Edit -- https://master.php.net/note/edit/104785 Del: integrated -- https://master.php.net/note/delete/104785/integrated Del: useless -- https://master.php.net/note/delete/104785/useless Del: bad code -- https://master.php.net/note/delete/104785/bad+code Del: spam -- https://master.php.net/note/delete/104785/spam Del: non-english -- https://master.php.net/note/delete/104785/non-english Del: in docs -- https://master.php.net/note/delete/104785/in+docs Del: other reasons-- https://master.php.net/note/delete/104785 Reject -- https://master.php.net/note/reject/104785 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181307) next »