+ 22
Why false value in 2nd echo is not giving output 0?
<?php echo 2==2; echo 2==3; ?> In first echo true outputting 1. Does it mean in php expressions evaluated to false don't output.
3 Réponses
+ 4
In php, 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.
Source (php documentation)👇
https://www.php.net/manual/en/language.types.string.php
+ 10
Arsenic
I thaught like c++ boolean false convert to 0.
Thank you for your answer.
+ 2
If it is necessary to print false as integer, we can cast the evaluation result into integer
echo (int)(2 == 3);