#25763 [Opn->WFx]: Why the string "1.10" is equal to the string "1.1"?
| From: | pollita@php.net | Date: | Mon, 06 Oct 2003 18:18:47 +0000 |
| Subject: | #25763 [Opn->WFx]: Why the string "1.10" is equal to the string "1.1"? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48591@lists.php.net to get a copy of this message | ||
ID: 25763
Updated by: pollita@php.net
Reported By: jparneodo at yahoo dot fr
-Status: Open
+Status: Wont fix
Bug Type: Strings related
Operating System: RH7.2
PHP Version: 4.3.3
New Comment:
Answer: Because PHP is a loose-typed lanague.
== will evaluate to TRUE if the two values CAN be shown to be equal
within reason.
Calling 1.1 equal to 1.10 is within reason.
You clearly know about the === comparison type so I won't bother
pointing that out.
Previous Comments:
------------------------------------------------------------------------
[2003-10-06 14:08:02] jparneodo at yahoo dot fr
Description:
------------
I excepted true if one of the compared variable was numeric,
because of type juggling rules (Appendix K. PHP type comparison
tables), but false when the 2
variables are string.
In this case == and === must have the same result.
Reproduce code:
---------------
$a=(string)"1.1";
$b=(string)"1.10";
if($a==$b) echo "equal";
else echo "different";
Expected result:
----------------
different
Actual result:
--------------
equal
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25763&edit=1