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,
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php