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.22, 8.5.0 - 8.5.7
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.31, 8.3.0 - 8.3.31
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:
60.73 ms | 876 KiB | 4 Q