Abstract Class
<?php
abstract class ParentClass
{
public $name;
abstract protected function calculation($a, $b);
}
class ChildClass extends ParentClass
{
public function calculation($c, $d)
{
echo $c + $d;
}
}
$test = new ChildClass();
$test->calculation(10,20);
//We Can't create the Object of Abstract Class and Abstract Class Must contains Abstract Methods
//Abstract methods doesn't have body. Abstract Methods must be implemented in the Child class
// OUTPUT:
//30
?>
Comments
Post a Comment