$foo = 0;
if($foo == 'on') $foo = 1;
echo $foo;
It should be expected the above code outputs "0". However it doesn't, somehow $foo == 'on'
results in TRUE
, although this obviously is wrong. Replacing the expression with $foo === 'on'
gives the right answer, so any suspicions this might be some typing issue seem to be confirmed.
Nevertheless, how can PHP think $foo
was 'on'
if $foo
and 'on'
even aren't of the same type? Is this a bug or some weird feature?