Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
OOP

Abstract Classes

Define partial base classes that cannot be instantiated directly.

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; }
}

Leave a reply

Your email address will not be published. Required fields are marked *