Re: [off] PHP: a fractal of bad design

From: Date: Mon, 07 May 2012 12:38:01 +0000
Subject: Re: [off] PHP: a fractal of bad design
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-60509@lists.php.net to get a copy of this message
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) 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) -- hartmut

« previous php.internals (#60509) next »