3v4l.org

run code in 500+ PHP versions simultaneously
<?php $fibonnacci = function (int $n, $previous2 = 0, $previous1 = 1) { if ($n <= 1) { return $previous2 + $previous1; } $closure = Closure::getCurrent(); return $closure($n - 1, $previous1, $previous1 + $previous2); }; print $fibonnacci(4);
Output for 8.5.7 - 8.5.9
5
Output for 8.4.9 - 8.4.24
Fatal error: Uncaught Error: Call to undefined method Closure::getCurrent() in /in/cdKnN:8 Stack trace: #0 /in/cdKnN(12): {closure:/in/cdKnN:3}(4) #1 {main} thrown in /in/cdKnN on line 8
Process exited with code 255.
Output for 8.2.32, 8.3.5 - 8.3.33
Fatal error: Uncaught Error: Call to undefined method Closure::getCurrent() in /in/cdKnN:8 Stack trace: #0 /in/cdKnN(12): {closure}(4) #1 {main} thrown in /in/cdKnN on line 8
Process exited with code 255.

preferences:
43.31 ms | 535 KiB | 4 Q