If you compare an integer with a string, each string is converted to a number, therefore:
(0 == 'all') -> (0 == 0) -> true
Type conversion does not occur when a comparison === or !== , as this also includes a type comparison:
(0 === 'all') -> (integer == string) -> false
The second line of code you wrote forces the integer value to be considered a string, so the numeric value is not executed.
source share