$o = 0.1;
for($a = 1; $a $o += 0.1;
echo "
intval('$o') = ".intval($o);
if(intval($o)){
print(" true");
}else{
print(" false");
}
}
?>
结果:
intval('0.2') = 0 false
intval('0.3') = 0 false
intval('0.4') = 0 false
intval('0.5') = 0 false
intval('0.6') = 0 false
intval('0.7') = 0 false
intval('0.8') = 0 false
intval('0.9') = 0 false
intval('1') = 0 false
intval('1.1') = 1 true
intval('1.2') = 1 true
intval('1.3') = 1 true
intval('1.4') = 1 true
intval('1.5') = 1 true
intval('1.6') = 1 true
intval('1.7') = 1 true
intval('1.8') = 1 true
intval('1.9') = 1 true
intval('2') = 2 true
intval('2.1') = 2 true
intval('2.2') = 2 true
intval('2.3') = 2 true
intval('2.4') = 2 true
intval('2.5') = 2 true
intval('2.6') = 2 true
intval('2.7') = 2 true
intval('2.8') = 2 true
.....
发现 intval(1) 竟然返回 0
不测试不会知道的
假象:
print("
intval(\"1.0\") = ".intval("1.0"));
print("
intval('1.0') = ".intval('1.0'));
print("
intval('1') = ".intval('1'));
intval("1.0") = 1
intval('1.0') = 1
intval('1') = 1
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn