|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25763 Why the string "1.10" is equal to the string "1.1"?
Submitted: 2003-10-06 14:08 UTC Modified: 2003-10-06 14:18 UTC
From: jparneodo at yahoo dot fr Assigned:
Status: Wont fix Package: Strings related
PHP Version: 4.3.3 OS: RH7.2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2003-10-06 14:08 UTC] jparneodo at yahoo dot fr
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:
if($a==$b) echo "equal";
else echo "different";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-06 14:18 UTC]
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.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 04:01:27 2023 UTC