2010/10/15 Iñaki Baz Castillo ibc@aliax.net:
- Never do implicit type conversion. This is, a string is NEVER equal
to an integer:
if "0" == 0 => false if "" == 0 => false if "asdasd" == 0 => false
- An integer is NEVER equal to a string:
if 0 == "0" => false if 0 == "" => false if 0 == "asdasd" => false
- Integer 0 is not equal to NULL:
if 0 == NULL => false
- Empty string is not equal to NULL:
if "" == NULL => false
- Integer 0 is true:
if 0 => true
- Empty string is true:
if "" => true
These simple rules avoid stupid problems (as they occur in PHP):
http://www.otton.org/2008/08/06/stupid-php-tricks-true-false-comparison/