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

From: Date: Wed, 09 May 2012 08:09:19 +0000
Subject: Re: [off] PHP: a fractal of bad design
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Nothing's stopping you from using === for integer comparison or validating your integer string using either ctype_digit() or is_numeric() before comparing it. (The difference between these two functions is is_numeric() allows for decimal points)

On 05/07/2012 09:25 PM, Raymond Irving wrote:
I was very surprised when I came across the == issue sometime ago. IMO strings should be compared as strings. They should never be converted to integer.
1=="1"          // always convert the number value to a string and then
compare it
"foo" == 0    //  should return false
"123abc" == "123nth" // compare as string. Do not convert to numeric values
"0"==0     //  true
0=="0." // false PHP is great but if we can work together to remove the flaws, then we can make it even greater. We have to leave the past behind us and look at where we want PHP to be in the next 5 years Best regards,


Thread (42 messages)

« previous php.internals (#60522) next »