3v4l.org

run code in 200+ PHP versions simultaneously
<?php function add(int $a, int $b): int { return $a + $b; } $c = Closure::fromCallable('add'); $r = new ReflectionFunction($c); echo $r; $c = fn(...$args) => add(...$args); $r = new ReflectionFunction($c); echo $r;
Output for 7.4.0 - 7.4.2
Closure [ <user> function add ] { @@ /in/XBOmJ 3 - 3 - Parameters [2] { Parameter #0 [ <required> int $a ] Parameter #1 [ <required> int $b ] } - Return [ int ] } Closure [ <user> function {closure} ] { @@ /in/XBOmJ 9 - 9 - Parameters [1] { Parameter #0 [ <optional> ...$args ] } }
Output for 7.2.0 - 7.3.14
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/XBOmJ on line 9
Process exited with code 255.