3v4l.org

run code in 300+ PHP versions simultaneously
<?php function curry($f, ...$argsCurried) { return function(...$args) use($f, $argsCurried) { $finalArgs = array_merge($argsCurried, $args); return call_user_func_array($f, $finalArgs); }; } function add($n1, $n2) { return $n1 + $n2; } $addFive = curry('add', 5); echo $addFive(2), PHP_EOL; echo $addFive(-5), PHP_EOL;
Output for 7.1.0 - 7.1.21, 7.2.0 - 7.2.33, 7.3.16 - 7.3.26, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
7 0