3v4l.org

run code in 300+ PHP versions simultaneously
<?php function volume(int $x, int $y, int $z): int { return $x * $y * $z; } class Action { public function volume(int $x, int $y, int $z): int { return $x * $y * $z; } static public function vol(int $x, int $y, int $z): int { return $x * $y * $z; } } function normalize(callable $callable) : ReflectionFunctionAbstract { return $callable instanceof \Partial ? new ReflectionPartial($callable) : new ReflectionFunction(Closure::fromCallable($callable)); }; $p = volume(3, 5, ?); $r1 = normalize($p); print $r1->getReturnType() . PHP_EOL; $r2 = normalize('volume'); print $r2->getReturnType() . PHP_EOL; $a = new Action(); $r3 = normalize([$a, 'volume']); print $r3->getReturnType() . PHP_EOL; $r4 = normalize(fn($z): int => volume(3, 5, $z)); print $r4->getReturnType() . PHP_EOL;
Output for 8.0.0 - 8.0.3
Parse error: syntax error, unexpected token "?", expecting ")" in /in/L3Qph on line 24
Process exited with code 255.
Output for 7.3.0 - 7.3.27, 7.4.0 - 7.4.16
Parse error: syntax error, unexpected '?', expecting ')' in /in/L3Qph on line 24
Process exited with code 255.

preferences:
162.69 ms | 1288 KiB | 6 Q