<?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();
You have javascript disabled. You will not be able to edit any code.