3v4l.org

run code in 300+ PHP versions simultaneously
<?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;
Output for git.master, git.master_jit, rfc.property-hooks
Test 2 to 5 --------------------------------- -10 → -10 -9 → -9 -8 → -8 -7 → -7 -6 → -6 -5 → -5 -4 → -4 -3 → -3 -2 → -2 -1 → -1 Fatal error: Uncaught Error: Undefined constant "min" in /in/im8Dk:7 Stack trace: #0 /in/im8Dk(17): repeatInt(0, 2, 5) #1 {main} thrown in /in/im8Dk on line 7
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
46.1 ms | 401 KiB | 8 Q