3v4l.org

run code in 500+ PHP versions simultaneously
<?php final readonly class SkipParamUsedAsInvokable { public function __construct(private string $name, private object $object) {} public function render(callable $formatter): string { return $formatter($this->name, $this->object); } } $obj = new SkipParamUsedAsInvokable('name', new \stdClass()); $obj->render(fn(string $label, object $object): string => ucfirst($label));
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Output for 8.1.34
Parse error: syntax error, unexpected token "readonly", expecting "abstract" or "final" or "class" in /in/DTYjM on line 3
Process exited with code 255.

preferences:
40.13 ms | 829 KiB | 4 Q