Very strange behaviour in PHP -
this question has answer here:
i have code:
$test = 0; if ($test == "on"){ echo "true"; } result of code be:
true why??? version of php: 5.4.10.
if compare number string or comparison involves numerical strings, each string converted number , comparison performed numerically. these rules apply switch statement. type conversion not take place when comparison === or !== involves comparing type value.
$test = 0; if ($test === "on"){ echo "true"; } php convert string number compare. using ===, compare value type of data.
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
Comments
Post a Comment