Since you are comparing $test
with a string value, not a binary value, if you want to compare with a string value, try comparing ===
, for value + dataType
.
In your example, var_dump(0=="on");
always returns bool(true)
.
But when you use var_dump(0==="on");
, it will give you bool(false)
.
An example from the PHP manual :
var_dump(0 == "a"); // 0 == 0 -> true var_dump("1" == "01"); // 1 == 1 -> true var_dump("10" == "1e1"); // 10 == 10 -> true var_dump(100 == "1e2"); // 100 == 100 -> true
source share