3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); $sampleFunction = function(int $a, int $b, int $c) { return sprintf("a=%d; b=%d; c=%d", $a, $b, $c); }; $partialFunction = function(Closure $function, int $argument) { return function(...$args) use ($function, $argument) { return $function($argument, ...$args); }; }; $p = $partialFunction($sampleFunction, 1); $p1 = $partialFunction($p, 2); $p2 = $partialFunction($p1, 4); echo $p2();
based on uXpHn
Output for hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0beta1
a=1; b=2; c=4
Output for 5.6.0 - 5.6.30
Warning: Unsupported declare 'strict_types' in /in/iC7hK on line 2 Catchable fatal error: Argument 2 passed to {closure}() must be an instance of int, integer given, called in /in/iC7hK on line 16 and defined in /in/iC7hK on line 9
Process exited with code 255.