#34896 [Opn->Bgs]: Error in control structures between integer and string
| From: | tony2001@php.net | Date: | Mon, 17 Oct 2005 18:35:40 +0000 |
| Subject: | #34896 [Opn->Bgs]: Error in control structures between integer and string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86662@lists.php.net to get a copy of this message | ||
ID: 34896
Updated by: tony2001@php.net
Reported By: decryptus at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Linux debian
PHP Version: 4.4.0
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Use "===" operator for that.
Previous Comments:
------------------------------------------------------------------------
[2005-10-17 20:31:45] decryptus at gmail dot com
Description:
------------
I have a problem when I compare two variables, one is an integer the
other is a string.
So when I do a "if" between these variables, the result is true.
I use '==' to compare these variables, I can use '===', but in the
logic two differents values should'nt be true.
Reproduce code:
---------------
-------------------
$foo_1 = 2005; # an integer
$foo_2 = '2005-10'; # a string
if($foo_1 == $foo_2)
print 'result true : '.$foo_1;
else
print 'result false : '.$foo_2;
-------------------
Expected result:
----------------
# foo_2's value :
result false : 2005-10
Actual result:
--------------
# foo_1's value :
result true : 2005
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34896&edit=1