3v4l.org

run code in 300+ PHP versions simultaneously
<?php $assertions = [ 1 => 1, 4 => 4, 5 => 5, 6 => 4, 8 => 2, 9 => 1, 10 => 2, 11 => 3, 12 => 4, 13 => 5, 14 => 4, 15 => 3, 16 => 2, 17 => 1, 18 => 2, 19 => 3, 20 => 4, 21 => 5, 22 => 4, ]; /** * @param positive-int $count * @return positive-int */ function countFingerPingPong(int $count): int { return abs(((abs($i-5)%8))-4)+1; } foreach($assertions as $count => $assert) { if (countFingerPingPong($count) !== $assert) { throw new Exception('Assesstions failed.'); } }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Warning: Undefined variable $i in /in/I9SiV on line 31 Fatal error: Uncaught Exception: Assesstions failed. in /in/I9SiV:36 Stack trace: #0 {main} thrown in /in/I9SiV on line 36
Process exited with code 255.

preferences:
68.82 ms | 402 KiB | 61 Q