note 104785 deleted from control-structures.if by googleguy
| From: | googleguy@php.net | Date: | Wed, 10 Oct 2012 20:39:29 +0000 |
| Subject: | note 104785 deleted from control-structures.if by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191246@lists.php.net to get a copy of this message | ||
Note Submitter: bimal at sanjaal dot com
----
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.