1.被除数不能为0,否则报错
<?php $a=100; $b=0; $c=$a/$b; echo $c; ?>
结果是Warning: Division by zero in D:\Apache\WebWorkspace\phptest\05.php on line 4
2.两个int型相加,如果超出范围,就会转为float型
<?php $a=2000000000; $b=1000000000; var_dump($a,$b); $c=$a+$b;var_dump($c); ?>
输出是int(2000000000) int(1000000000) float(3000000000)
3.取模运算中,结果的正负取决于被除数的正负
<?php var_dump(10%3,10%-3,-10%3,-10%-3); ?>
输出是int(1) int(1) int(-1) int(-1)
时间: 2024-10-12 21:14:29