Abstract Classes — a practical guide to PHP abstract class with clear examples you can reuse in real projects.
OOP Tutorial Series (26/65). Prefer one article? Read the complete OOP tutorial.
Short description
Abstract classes can include shared code plus abstract methods children must implement.
Abstract class
abstract class PaymentGateway {
abstract public function charge(int $amount): bool;
public function currency(): string { return 'INR'; }
}
class StripeGateway extends PaymentGateway {
public function charge(int $amount): bool { return true; }
}