3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sum = function ($a, $b) { return $a + $b; }; function calc($value_or_function, array $buffer = []) { if (is_callable($value_or_function)) { if (count($buffer) === 0) { throw new \InvalidArgumentException('Not enough parameters.'); } return array_reduce(array_slice($buffer, 1), $value_or_function, $buffer[0]); } return static function ($otherValue) use ($buffer, $value_or_function) { return calc($otherValue, array_merge($buffer, [$value_or_function])); }; } echo calc(5)(4)(3)($sum), PHP_EOL; echo calc(5)(2)(2)('pow');
Output for git.master, git.master_jit, rfc.property-hooks
12 625

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
178.99 ms | 405 KiB | 5 Q