3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class AAA { public function foo () { echo $this->childValue(); } abstract public function childValue(): string; } class XXXXXX extends AAA { public function childValue (): string { return "x"; } } class YYYYYY extends AAA { public function childValue (): string { return "y"; } } class ZZZZZZ extends AAA { public function childValue (): string { return "z"; } } //class WRONG extends AAA { // if empty: // Fatal error: Class WRONG contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (AAA::childValue) in /tmp/preview on line 29 //} $objX = new XXXXXX(); $objX->foo(); $objY = new YYYYYY(); $objY->foo(); $objZ = new ZZZZZZ(); $objZ->foo();
Output for 8.1.25 - 8.1.33, 8.2.12 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
xyz

preferences:
65.08 ms | 406 KiB | 5 Q