3v4l.org

run code in 500+ PHP versions simultaneously
<?php abstract class A { public function writeFromA(): void { $this->prop = 'a'; } } final class B extends A { public readonly string $prop; } $object = new B(); $object->writeFromA();
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35
Fatal error: Uncaught Error: Cannot initialize readonly property B::$prop from scope A in /in/XFLc4:7 Stack trace: #0 /in/XFLc4(17): A->writeFromA() #1 {main} thrown in /in/XFLc4 on line 7
Process exited with code 255.
Output for 8.4.1 - 8.4.26, 8.5.0 - 8.5.11

preferences:
35.94 ms | 1155 KiB | 9 Q