在PHP中为什么是真正的转换1和false转换为空字符串?

时间:2012-03-10 01:35:31

标签: php casting boolean

  

布尔值TRUE值转换为字符串“1”。 Boolean FALSE转换为“”(空字符串)。

为什么FALSE不能转为“0”?

1 个答案:

答案 0 :(得分:0)

如果你转换为int,然后转换为字符串,它会输出0 ..

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

打印0.当然,你可以省略字符串类型,因为它是通过打印完成的。

相关问题