3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public int $bar { get => $this->bar; set => empty($this->bar) ? $this->bar = $value : throw new LogicException("nope"); } } $foo = new Foo; $foo->bar = 0; var_dump($foo->bar); $foo->bar = 1; // no error ! var_dump($foo->bar);
Output for 8.4.10
int(0) int(1)
Output for 8.3.5
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/iUPvW on line 4
Process exited with code 255.

preferences:
43.19 ms | 492 KiB | 3 Q