> On 05/07/2012 05:32 AM, Tjerk Anne Meesters wrote: > >> Validated or not, why would type juggling even come into the picture >> if both variables are of the same type? > > For the simple reason that web forms return all input as strings, even > if the input is actually meant to be numeric > > Many PHP database backend functions also return all result fields > as strings regardless of the actual result type, e.g. mysql_fetch_*(), > mysqli_fetch_*() and pg_fetch_*() (although that's more debatable)
Granted, I realized that my comment came across a bit too generic. What I meant to say is that the type juggling should be applied within its realm of usefulness and skipped otherwise lest it tell me "they're both pretty big numbers" :) I've always felt overly pedantic when I used === or strcmp() in string comparisons (assuming the equality edge cases were not an issue; e.g. same string composition). > > So if both operands look numeric (even though they are actually of > type string) type juggling kicks, and in your MD5 example it > unfortunately kicks in with a conversion to float for both sides > and you're running into the "never compare floats for equality" > trap ... (which is being worked on for the string comparison case > though, i just don't have the bug number at hand right now) I'm assuming that you're referring to this bug reference: https://bugs.php.net/bug.php?id=54547 The proposed patch therein looks okay, though I'm not sure why the added test case is for 64bit systems only; seems to me that it can / should be run for other systems too. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php