Inheritance
extends inherits members and parent:: calls the parent. Override methods in the child.
Example
class A { function hi() { return "A"; } }
class B extends A { function hi() { return parent::hi() . "B"; } }
echo (new B)->hi();Result
AB
Exercise
Inherit from a class.
class B A {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.