3v4l.org

run code in 500+ 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.2.0 - 8.2.34, 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.
Output for 8.4.1 - 8.4.11
1000

preferences:
28.95 ms | 1154 KiB | 8 Q