Edit report at https://bugs.php.net/bug.php?id=54547&edit=1
ID: 54547 Updated by: ahar...@php.net Reported by: peter dot ritt at gmx dot net Summary: wrong equality of string numbers Status: Not a bug Type: Bug Package: Unknown/Other Function Operating System: linux PHP Version: 5.3.6 Assigned To: dmitry -Block user comment: No +Block user comment: Yes Private report: N New Comment: Enough. Gustavo has written a patch, the technical merits of which can be discussed somewhere with less noise. Additionally, it would be nice if the anti-PHP circlejerk took place somewhere other than PHP's bug tracker. Hacker News seems to enjoy it. Closing the bug to public comments. Feel free to e-mail me about how I hate freedom, if it makes you feel better. Previous Comments: ------------------------------------------------------------------------ [2012-04-13 11:30:30] the dot assimilator at gmail dot com This isn't just a bug, it's a summary of PHP as a language: broken by design. ------------------------------------------------------------------------ [2012-04-13 10:53:24] ses...@php.net This behaviour is for sure a bug. The == vs. === argument does not apply here. PHP should not perform the type conversion for the comparison if the result of the type conversion does not fit into the actual type converted to. ------------------------------------------------------------------------ [2012-04-13 10:15:52] yohg...@php.net Just a comment for users who would like to use large numbers. There are bcmath and gmp modules for large number arithmetic. ------------------------------------------------------------------------ [2012-04-13 07:08:00] paj...@php.net ok, enough arguing. There is no bug here. ------------------------------------------------------------------------ [2012-04-13 03:13:57] four dot zero dot one dot unauthorized at gmail dot com This behavior is documented here: http://php.net/manual/en/language.operators.comparison.php "If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement. The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value. " Shouldn't this feature of converting numerical strings to numbers during loose comparison operations between two strings be dropped? If a developer wanted to compare values given during POST or GET processing AS numbers, they should cast the inputs to (int) or (float) first. There really should be a fundamental shift away from catering to developer laziness, and force developers to pay more attention to variable and input handling on their own. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=54547 -- Edit this bug report at https://bugs.php.net/bug.php?id=54547&edit=1