==
converts to numbers when possible (123 == "123foo")
, which means it converts to floats when possible. So large hex strings (like, say, password hashes) may occasionally compare TRUE
when they’re not. So "6" == " 6"
, "4.2" == "4.20"
, and "133" == "0133"
. But note that 133 != 0133
, because 0133
is octal. But "0x10" == "16"
and "1e3" == "1000"
!===
compares values and type… except with objects, where ===
is only true if both operands are actually the same object! For objects, ==
compares both value (of every attribute) and type, which is what ===
does for every other type.NULL < -1
, and NULL == 0
.<
and >
operators try to sort arrays, two different ways: first by length, then by elements. If they have the same number of elements but different sets of keys, though, they are uncomparable. Objects compare as greater than anything else… except other objects, which they are neither less than nor greater than.==
, we have ===
. For a more type-safe <
, we have… nothing. "123" < "0124"
, always, no matter what you do. Casting doesn’t help, either.global
declaration before they can be used.$foo[] = $bar