class ParentClass { public function foo() { return "This is the parent class function."; } } class ChildClass extends ParentClass { public function bar() { return "This is the child class function."; } } $child = new ChildClass(); echo $child->foo(); // Output: This is the parent class function. echo $child->bar(); // Output: This is the child class function.
class ParentClass { public function foo() { return "This is the parent class function."; } } class ChildClass { private $parent; public function __construct(ParentClass $parent) { $this->parent = $parent; } public function bar() { return "This is the child class function."; } public function foo() { return $this->parent->foo(); } } $parent = new ParentClass(); $child = new ChildClass($parent); echo $child->foo(); // Output: This is the parent class function. echo $child->bar(); // Output: This is the child class function.The add_extension function is part of the PHP standard library, which is included with every installation of PHP. It doesn't require any additional packages or libraries to be installed.