Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 704 Bytes

0_to_string_comparison.md

File metadata and controls

31 lines (25 loc) · 704 Bytes

0 to string comparison

On compare an integer 0 with a string you'll get TRUE if the string isn't "1".

(See PHP documentation of Loose comparisons with ==)

Example:

(http://3v4l.org/e1i2O)

var_dump(array(
    '0 == "one"'  => (0 == "one"),
    '0 == "null"' => (0 == "null"),
    '0 == "1"'    => (0 == "1"),
    '0 == "0"'    => (0 == "0"),
    '0 == ""'     => (0 == ""),
));
array(5) {
    ["0 == "one""]  => bool(true),
    ["0 == "null""] => bool(true),
    ["0 == "1""]    => bool(false),
    ["0 == "0""]    => bool(true),
    ["0 == """]     => bool(true),
}