3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function repeatInt(int $val, int $min, int $max) { $validValueNum = $max - $min + 1; $result = ($val %$validValueNum + $min) % $validValueNum; if ($result< 0) { $result= $validValueNum + $result; } return $min + $result; } // ?????? foreach (range(-10, 5) as $i) echo $i .'='. repeatInt($i, 2, 5) . PHP_EOL;
based on UNUi8
Output for 7.0.28 - 7.3.0rc3
-10=2 -9=3 -8=4 -7=5 -6=2 -5=3 -4=4 -3=5 -2=2 -1=3 0=4 1=5 2=2 3=3 4=4 5=5
Output for 5.6.38
Catchable fatal error: Argument 1 passed to repeatInt() must be an instance of int, integer given, called in /in/htUj9 on line 16 and defined in /in/htUj9 on line 2
Process exited with code 255.