3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(int $a) { var_dump($a); } function define_callbacks() { $string = 'foo'; $lambda = fn(...$args) => foo(...$args); $fcc = foo(...); return [$string, $lambda, $fcc]; } function test_callback($callback) { $callback(1); try { $callback(new class{}); } catch ( TypeError $e ) { echo $e->getMessage(), "\n"; } } [$string, $lambda, $fcc] = define_callbacks(); echo "== String-based ==\n"; test_callback($string); echo "\n== Type-less lambda ==\n"; test_callback($lambda); echo "\n== First-class callable ==\n"; test_callback($fcc);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.120.0120.00820.51
8.4.110.0070.00322.52
8.4.100.0090.01118.03
8.4.90.0090.00418.71
8.4.80.0140.00319.48
8.4.70.0040.00518.04
8.4.60.0060.00518.69
8.4.50.0110.00518.02
8.4.40.0070.01320.76
8.4.30.0000.00918.73
8.4.20.0090.00019.90
8.4.10.0060.00324.14
8.3.250.0120.00618.62
8.3.240.0120.00816.60
8.3.230.0050.00616.70
8.3.220.0110.00816.98
8.3.210.0020.00616.81
8.3.200.0040.00416.76
8.3.190.0040.00417.23
8.3.180.0100.00716.54
8.3.170.0090.00918.79
8.3.160.0080.00016.60
8.3.150.0080.01117.20
8.3.140.0000.01517.34
8.3.130.0050.00318.61
8.3.120.0070.00319.10
8.3.110.0130.00616.69
8.3.100.0120.00416.59
8.3.50.0080.00016.63
8.2.290.0110.00920.43
8.2.280.0040.00322.41
8.2.270.0140.00418.51
8.2.260.0090.00020.67
8.2.250.0040.00720.59
8.2.240.0040.00418.96
8.2.230.0030.00618.48
8.2.220.0190.00016.70
8.2.30.0040.00419.44
8.1.330.0080.01120.12
8.1.320.0100.00816.34
8.1.310.0060.01216.43
8.1.300.0090.00620.06

preferences:
29.19 ms | 403 KiB | 5 Q