PHP

How to demonstrate the example of the simple abstract class in PHP | PHP programs

How to demonstrate the example of the simple abstract class in PHP | PHP programs

How to demonstrate the example of the simple abstract class in PHP | PHP programs

We will create an abstract class that contains abstract methods and then inherited the abstract class into a non-abstracted class and definition abstract methods.

<?php


abstract class AbsClass
{
    public abstract function fun1();
    public abstract function fun2();
}

class Sample extends AbsClass
{
    public function fun1()
    {
        printf("fun1() called<br>");
    }
    public function fun2()
    {
        printf("fun2() called<br>");
    }
}

$obj = new Sample();

$obj->fun1();
$obj->fun2();
?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community