Inheritance is very important and useful property of
the Object Orient Programming. By this inheritance we can share any method from
one class to another class. Inheritance means to inherit the property of one
class to another. The main class is know the parent class, super class and base
class and which class can inherit the property called sub class, child class
and derived class. Inheritance is share method and we don’t need to define
every time any method in class.
Here class can declare with class keyword. A Class is collection of data variable and data member. Each class has unique name.
Here class can declare with class keyword. A Class is collection of data variable and data member. Each class has unique name.
Syntax:
Class New_class extends Old_class
{
Variable;
Method;
}
Program:
<?php
Class sum
{
Var $sum;
function sum($first, $sec)
{
$this->sum=$first+$sec;
return $this ->sum;
echo “sum is =”. $this->sum .”<br>”;
}}
Class dic extends sum
{
Var div;
function div($res)
{
$this->dic=$res/2;
return
$this->dic;
echo “div is= “. $this ->div.”<br>”;
}}
$obj=new div();
$add=$obj->sum(12, 30);
$obj->div($add);
?>
}
Here video Tutorial
Here video Tutorial