3v4l.org

run code in 500+ PHP versions simultaneously
<?php function calc($x) { return function($y = null) use ($x) { if (is_callable($y)) { return $y(...$x); } else { $args = (array) $x; $args[] = $y; return calc($args); } }; } $sum = function(...$args) { return array_sum($args); }; echo calc(5)(3)(2)($sum), PHP_EOL; echo calc(1)(2)($sum), PHP_EOL; echo calc(2)(3)('pow'), PHP_EOL;
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
10 3 8
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /in/r0emm on line 18
Process exited with code 255.

preferences:
80.19 ms | 1996 KiB | 4 Q