3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function Kmod($bn, $sn) { return intval(fmod(floatval($bn), $sn)); } //整数取余方法 function mod($bn, $sn) { return $bn%$sn; } //最大的int整数 $bn = PHP_INT_MAX; $sn = 11; var_dump($bn); var_dump(Kmod($bn, $sn)); var_dump(mod($bn, $sn)); //给最大的int整数加1 当给最大的整型数加1之后,得到的$bn已经变为了浮点型。 $bn = PHP_INT_MAX + 1; var_dump($bn); var_dump(Kmod($bn, $sn)); var_dump(mod($bn, $sn));
Output for 4.4.0 - 4.4.9, 5.0.5 - 7.1.0
int(9223372036854775807) int(8) int(7) float(9.2233720368548E+18) int(8) int(-8)
Output for 4.3.0 - 4.3.11, 5.0.0 - 5.0.4
Notice: Use of undefined constant PHP_INT_MAX - assumed 'PHP_INT_MAX' in /in/Q8vEm on line 13 string(11) "PHP_INT_MAX" int(0) int(0) Notice: Use of undefined constant PHP_INT_MAX - assumed 'PHP_INT_MAX' in /in/Q8vEm on line 21 int(1) int(1) int(1)