|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-14 15:41 UTC] colder@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 11:00:01 2025 UTC |
Description: ------------ I have noticed that the equal operator will systematically try to cast expressions as integers, even when it is useless. This may cause problems like this (see the code below). Wouldn't be better to cast only one operand ONLY if the two operands are not of the same type ? For example : "1" == 1 , would cast the right operand (1) as a string and then compare it with the first "123" == "456", would not cast any operand because they already have the same type I know that this issue can be solved using the identity operator (===) but I find weird that "001" == "0001" returns true, or am I missing something ? Reproduce code: --------------- <?php if ("0001" == "000001"){ echo "Impossible !!!"; } ?> Expected result: ---------------- Nothing Actual result: -------------- Impossible !!!