3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected int $v = 2; public function setValue(A $v, int $i): void { $v->v = $i; } public function getValue(A $v): void { echo $v->v; } } class B extends A { protected int $v { set => 1000; } } $a = new A; $b = new B; $a->setValue($b, 42); $a->getValue($b);
Output for 8.4.1 - 8.4.11
1000
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.24
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/OEadK on line 14
Process exited with code 255.

preferences:
160.88 ms | 1001 KiB | 7 Q