In PHP, when you compare 2 types, it must convert them to the same type. In your case, you are comparing string with int . Internally, this translates to
if((int)'van'==0).... and then if((int)'van'==1)....
(int) "any possible string" will be 0 :) Thus, you need to either manually convert both values ββto the same type, or use === as a comparison operator instead of a free = , an exception to this rule (as indicated in comments) it would be if the line starts with a number or can be interpreted as a number in any way (1, 0002, -1, etc.). In this case, the string will be interpreted as a number defining the end of the non-numeric end of the string
See http://php.net/manual/en/types.comparisons.php for more details.
Quamis
source share