3v4l.org

run code in 300+ 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.10
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.29, 8.3.0 - 8.3.23
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.

preferences:
57.2 ms | 412 KiB | 5 Q