PHP theorytheory 0/50 · 0%
OOP · easy

14. Interfaces

Defining contracts.

An interface declares method signatures without implementations, and classes agree to fulfil that contract using the implements keyword. A class can implement multiple interfaces, unlike single class inheritance.

Interfaces enable polymorphism: code can depend on an interface type rather than a concrete class, easing testing and substitution.

Check your understanding

  1. 1. How does a class fulfil an interface?

  2. 2. Can a class implement multiple interfaces?