After a few hours of frustration, I found that 0 == "empty" evaluates as true.
I can understand why 0 == "null" would be true and why 0 === null would be false, but I don't get what's happening above.
Can anyone explain this to me?
Thank you.
Why does 0 == 'empty'?
Moderator: General Moderators
Re: Why does 0 == 'empty'?
0 is equal to any string, that does not begin with a number.
This is because when you are comparing two different types, one of the operands is cast to the type of the another.
And when you cast a string to integer, it becomes 0 (or if it begins with numbers, it becomes the numeric part of the string)
You can read more at http://php.net/manual/en/language.opera ... arison.php
This is because when you are comparing two different types, one of the operands is cast to the type of the another.
And when you cast a string to integer, it becomes 0 (or if it begins with numbers, it becomes the numeric part of the string)
You can read more at http://php.net/manual/en/language.opera ... arison.php
Re: Why does 0 == 'empty'?
Okay, got it now. Apparently I did not understand why 0 == 'null' 
Thank you, that was really bothering me.
Thank you, that was really bothering me.