Welcome Guest, Not a member yet? Register   Sign In
Why is this true?
#2

[eluser]mddd[/eluser]
If a comparison involves a number, the other item is also converted to a number.
So php converts 'text' to a number and then compares the two.
'text' converted to a number equals 0 because it doesn't start with a digit.
So $key == 'text' becomes 0 == 0 and that's true.

Bottom line: if you want to compare something to a text, make sure it is not a number..
$key = ''; or $key = false; would probably both have worked like you expect.


Messages In This Thread
Why is this true? - by El Forum - 07-27-2010, 02:13 AM
Why is this true? - by El Forum - 07-27-2010, 02:21 AM
Why is this true? - by El Forum - 07-27-2010, 02:25 AM
Why is this true? - by El Forum - 07-27-2010, 05:38 AM
Why is this true? - by El Forum - 07-27-2010, 11:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB