我只是检查我的以下php代码。它应该显示0,但为什么它显示我1?你能解释一下吗?
<?php
$x = (bool) " " * (int) (string) 12E-1;
echo $x;
?>
output: 1
答案 0 :(得分:1)
$a = (bool) " ";//true
$b = (string) 12E-1;//"1.2"
$c = (int) $b;//1
$x = $a * $c;//true * 1, typecasting to int
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($x);
//prints bool(true) string(3) "1.2" int(1) int(1)