3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function repeatInt(int $value, int $min, int $max) { $validValueNum = $max - $min + 1; $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 tEUVJ
Output for 7.2.0 - 7.3.0rc3
Test 2 to 5 --------------------------------- Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -10 → -2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -9 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -8 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -7 → -3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -6 → -2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -5 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -4 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -3 → -3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -2 → -2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -1 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 0 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 1 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 2 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 3 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 4 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 5 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 6 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 7 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 8 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 9 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 10 → 2 Test 3 to 8 --------------------------------- Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -10 → -4 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -9 → -3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -8 → -2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -7 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -6 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -5 → -5 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -4 → -4 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -3 → -3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -2 → -2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -1 → -1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 0 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 1 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 2 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 3 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 4 → 4 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 5 → 5 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 6 → 0 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 7 → 1 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 8 → 2 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 9 → 3 Warning: Use of undefined constant min - assumed 'min' (this will throw an Error in a future version of PHP) in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 10 → 4
Output for 7.1.0 - 7.1.23
Test 2 to 5 --------------------------------- Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -10 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -9 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -8 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -7 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -6 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -5 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -4 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -3 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -2 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 4 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 5 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 6 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 7 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 8 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 9 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 10 → 2 Test 3 to 8 --------------------------------- Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -10 → -4 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -9 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -8 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -7 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -6 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -5 → -5 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -4 → -4 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -3 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -2 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 4 → 4 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 5 → 5 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 6 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 7 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 8 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 9 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 Warning: A non-numeric value encountered in /in/Irmra on line 6 10 → 4
Output for 7.0.28
Test 2 to 5 --------------------------------- Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -10 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -9 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -8 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -7 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -6 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -5 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -4 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -3 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -2 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 4 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 5 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 6 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 7 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 8 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 9 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 10 → 2 Test 3 to 8 --------------------------------- Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -10 → -4 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -9 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -8 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -7 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -6 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -5 → -5 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -4 → -4 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -3 → -3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -2 → -2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 -1 → -1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 0 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 1 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 2 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 3 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 4 → 4 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 5 → 5 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 6 → 0 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 7 → 1 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 8 → 2 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 9 → 3 Notice: Use of undefined constant min - assumed 'min' in /in/Irmra on line 6 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/Irmra on line 15 and defined in /in/Irmra on line 2
Process exited with code 255.