Extending Classes with Inheritance
Use extends to build class hierarchies and override methods.
Intro: PHP Inheritance
Inheritance lets a class (child) reuse and extend the code of another class (parent) using the extends keyword. PHP supports single inheritance.
Key Concepts
Key concepts:
- Child inherits all public/protected members
- Override parent methods to change behavior
- Call parent method with
parent:: - Use
finalto prevent overriding
All lessons in this course
- Extending Classes with Inheritance
- Abstract Classes and Methods
- Implementing Interfaces
- Traits for Code Reuse