3v4l.org

run code in 500+ PHP versions simultaneously
<?php readonly class C { public array $a; public function __construct() { $this->a = ['a', 'b', 'c', 'd']; } } $c = new C(); reset($c->a);
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Cannot indirectly modify readonly property C::$a in /in/Zo5dZ:13 Stack trace: #0 {main} thrown in /in/Zo5dZ on line 13
Process exited with code 255.
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: Uncaught Error: Cannot modify readonly property C::$a in /in/Zo5dZ:13 Stack trace: #0 {main} thrown in /in/Zo5dZ on line 13
Process exited with code 255.
Output for 8.1.34
Parse error: syntax error, unexpected token "readonly", expecting end of file in /in/Zo5dZ on line 3
Process exited with code 255.

preferences:
56.45 ms | 847 KiB | 4 Q