3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function repeatInt(int $value, int $min, int $max) { $validValueNum = $max - $min + 1; if ($value >= 0) { $value = $value % $validValueNum + min; } return $value; } echo 'Test 2 to 5' . PHP_EOL; echo '---------------------------------' . PHP_EOL; foreach (range(-10, 10) as $i) { echo $i . ' → ' . repeatInt($i, 2, 5) . PHP_EOL; } echo PHP_EOL; echo 'Test 3 to 8' . PHP_EOL; echo '---------------------------------' . PHP_EOL; foreach (range(-10, 10) as $i) { echo $i . ' → ' . repeatInt($i, 3, 8) . PHP_EOL; } echo PHP_EOL;
based on uYHIs
Output for 7.2.0 - 7.3.0rc3
Test 2 to 5 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 0 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 1 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 2 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 3 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 4 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 5 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 6 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 7 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 8 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 9 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 10 → 2 Test 3 to 8 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 0 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 1 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 2 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 3 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 4 → 4 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 5 → 5 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 6 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 7 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 8 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 9 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 10 → 4
Output for 7.1.0 - 7.1.23
Test 2 to 5 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 4 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 5 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 6 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 7 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 8 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 9 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 10 → 2 Test 3 to 8 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 4 → 4 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 5 → 5 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 6 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 7 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 8 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 9 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 Warning: A non-numeric value encountered in /in/im8Dk on line 7 10 → 4
Output for 7.0.28
Test 2 to 5 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 4 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 5 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 6 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 7 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 8 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 9 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 10 → 2 Test 3 to 8 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 4 → 4 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 5 → 5 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 6 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 7 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 8 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 9 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/im8Dk on line 7 10 → 4
Output for 5.6.38
Test 2 to 5 --------------------------------- Catchable fatal error: Argument 1 passed to repeatInt() must be an instance of int, integer given, called in /in/im8Dk on line 17 and defined in /in/im8Dk on line 2
Process exited with code 255.