3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function number_factory($num) { return function($operation) use ($num) { return $operation ? $operation($num) : $num; }; } function operation_factory($operation) { return function($b) use ($operation) { return function($a) use ($b, $operation) { return $operation($a, $b); }; }; } $plus = operation_factory(function($a, $b) { return $a+$b; }); $minus = operation_factory(function($a, $b) { return $a-$b; }); $times = operation_factory(function($a, $b) { return $a*$b; }); $dividedBy = operation_factory(function($a, $b) { return $a/$b; }); $zero = number_factory(0); $one = number_factory(1); $two = number_factory(2); $three = number_factory(3); $four = number_factory(4); $five = number_factory(5); $six = number_factory(6); $seven = number_factory(7); $eight = number_factory(8); $nine = number_factory(9); print($two($plus($three($minus($two())))));
Output for 7.1.0 - 7.2.6
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 0 passed in /in/roWqQ on line 33 and exactly 1 expected in /in/roWqQ:4 Stack trace: #0 /in/roWqQ(33): {closure}() #1 {main} thrown in /in/roWqQ on line 4
Process exited with code 255.
Output for 5.5.0 - 7.0.20
Warning: Missing argument 1 for {closure}(), called in /in/roWqQ on line 33 and defined in /in/roWqQ on line 4 Notice: Undefined variable: operation in /in/roWqQ on line 5 3
Output for 5.3.0 - 5.4.45
Warning: Missing argument 1 for {closure}(), called in /in/roWqQ on line 33 and defined in /in/roWqQ on line 4 3
Output for 5.2.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/roWqQ on line 4
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected T_FUNCTION in <b>/in/roWqQ</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_FUNCTION in <b>/in/roWqQ</b> on line <b>4</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/roWqQ</b> on line <b>4</b><br />
Process exited with code 255.