Inheritance

Inheritance lets a class extend another with extends: it takes over its properties and methods and can override them. parent:: calls the parent class version. PHP allows only one parent; composition is often preferred when the relationship is not "is a".

Example

class Chien extends Animal {
  public function crier(): string { return 'Wouf'; }
}

Related concepts

The whole glossary