3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public string $foo { #[\Deprecated] get { return $this->foo; } #[\Deprecated] set { $this->foo = $value; } } } $f = new Foo(); $f->foo = 'dummy'; var_dump($f->foo);
Output for 8.4.1 - 8.4.7
Deprecated: Method Foo::$foo::set() is deprecated in /in/C6jRQ on line 21 Deprecated: Method Foo::$foo::get() is deprecated in /in/C6jRQ on line 22 string(5) "dummy"
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.21
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/C6jRQ on line 6
Process exited with code 255.

preferences:
155.72 ms | 997 KiB | 7 Q