我想知道在什么条件下PHP决定何时从字符串到整数和周围的其他方法为什么PHP将String转换为Integer?
实例转换:
$key = 0;
$test = 'teststring';
if($key == $test) {
echo "Why, tell me why!";
}
else {
echo "That's the way love goes...";
}
我知道我应该用“===”得到更好结果,但我很想知道为什么PHP决定将字符串转换为整数而不是其他方式。
阅读此:http://php.net/manual/en/language.types.type-juggling.php – diEcho 2011-04-21 08:31:29