case 1:
echo false . 'test';
output:
test
case 2:
echo true . 'test';
output:
1test
Why true cast to 1 but false nothing?
case 1:
echo false . 'test';
output:
test
case 2:
echo true . 'test';
output:
1test
Why true cast to 1 but false nothing?
Simple:
A value can be converted to a string using the
(string)cast or thestrval()function. String conversion is automatically done in the scope of an expression where a string is needed. This happens when using theecho()orprint()functions, or when a variable is compared to a string.A boolean TRUE value is converted to the string
"1". Boolean FALSE is converted to""(the empty string). This allows conversion back and forth between boolean and string values.
http://php.net/manual/en/language.types.string.php#language.types.string.casting