Home » PHP » What is the Abstract class in PHP?

What is the Abstract class in PHP?

Abstract classes are the classes in which at least one method is abstract. All base classes implementing this class should give implementation of abstract methods declared in parent class. An abstract class can contain abstract as well as non abstract methods.

// Abstract class 
abstract class A { 
    // This is abstract function 
    abstract function C(); 
} 
class B extends A { 
    function C() { 
        echo "B class"; 
    } 
} 
    
$obj = new B; 
$obj->C(); 

Output -> B class

Check Also

What is the Polymorphism in PHP?

Polymorphism is one of the PHP Object Oriented Programming (OOP) features. Polymorphism is derived from …

Leave a Reply

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