3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(callable $x) { return $x(42); } function inc($x) { return $x + 1; } echo foo('inc'); echo foo('oops');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
43 Fatal error: Uncaught TypeError: foo(): Argument #1 ($x) must be of type callable, string given, called in /in/v9X2P on line 10 and defined in /in/v9X2P:3 Stack trace: #0 /in/v9X2P(10): foo('oops') #1 {main} thrown in /in/v9X2P on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
43 Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be callable, string given, called in /in/v9X2P on line 10 and defined in /in/v9X2P:3 Stack trace: #0 /in/v9X2P(10): foo('oops') #1 {main} thrown in /in/v9X2P on line 3
Process exited with code 255.

preferences:
95.49 ms | 1700 KiB | 4 Q