Inheritance & Interfaces in PHP
From the PHP cheat sheet · Object-Oriented PHP · verified Jul 2026
Inheritance & Interfaces
Extending classes and implementing interfaces
php
// Interface
interface Payable {
public function pay(float $amount): bool;
}
// Abstract class
abstract class Employee {
abstract public function calculateSalary(): float;
}
// Inheritance
class Developer extends Employee implements Payable {
public function calculateSalary(): float {
return 5000.00;
}
public function pay(float $amount): bool {
return true;
}
}💡 Interfaces define contracts, abstract classes provide partial implementation
⚡ Traits enable horizontal code reuse
📌 Use final to prevent inheritance
🔥 Late static binding with static:: for proper inheritance