In PHP, why do true cast 1 and false cast an empty string?

Boolean TRUE is converted to the string "1". Boolean FALSE is converted to "" (empty string).

Why doesn't FALSE add the value "0"?

+3


source to share


1 answer


If you added to int and then to string it prints 0 ..

$x=false;
print (string)(int)$x;

      



Fingerprints 0. You can, of course, omit the string type created by printing anyway.

0


source







All Articles