3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class Foo { public function __construct( public int $id, public string $name, ) { } } $foo = new Foo(1, 'foo'); $foo->id = 2; var_dump($foo);
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.15, 8.5.0
Fatal error: Uncaught Error: Cannot modify readonly property Foo::$id in /in/REik5:13 Stack trace: #0 {main} thrown in /in/REik5 on line 13
Process exited with code 255.

preferences:
52.84 ms | 406 KiB | 5 Q