I don't understand below output . found below expressions on php.net manual in boolean section.
<?php
var_dump(0 == 'all');// IS bool(true)
var_dump((string)0 == 'all'); //IS bool(false)
var_dump(0 === 'all'); // //IS bool(false)
?>
I don't understand below output . found below expressions on php.net manual in boolean section.
<?php
var_dump(0 == 'all');// IS bool(true)
var_dump((string)0 == 'all'); //IS bool(false)
var_dump(0 === 'all'); // //IS bool(false)
?>
If you compare an integer with a string, each string is converted to a number, so:
(0 == 'all') -> (0 == 0) -> true
The type conversion does not happen when the comparison is === or !== because this also includes the comparison of the type:
(0 === 'all') -> (integer == string) -> false
The second line of code you wrote force the integer value to be considered as a string, and so the numerical cast doesn't happen.