3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php phpversion() >= "7.0.0" or die(); $a = 5; $n = 2; echo $a % $n,"\n"; //echo mod($a,$n),"\n"; PHP doesn't have mod() but does have fmod(); see http://php.net/fmod echo fmod((float)$a,(float)$n),"\n"; echo $a - ($n * (int)($a/$n)),"\n"; $a = INF; $n = pow(2.,64.); try{ echo $a % $n,"\n"; } catch (Error $e){ echo $e->getMessage(),"\n"; } echo fmod((float)$a,(float)$n),"\n"; echo $a - ($n * (int)($a/$n)),"\n";
based on 7sErV
Output for 7.0.0 - 7.2.0
1 1 1 Modulo by zero NAN INF
Output for 5.3.20 - 5.6.28