# OVERRIDING-OVERLOADING

## Function Overriding :

##

Function definitions in child classes override definitions with the same name in parent classes. In a child class, we can modify the definition of a function inherited from parent class.
<?php
class abc
{
var $a;
var $b;
function cal($p,$q)
{
$this->a=$p;
$this->b=$q;
$sum=$this->a+$this->b;
echo”it is addition of two parameters”.$sum;
}
}
class xyz extends abc
{
var $a;
var $b;
var $c;
var $d;
function cal($p,$q)
{
$this->a=$p;
$this->b=$q;
$sum=$this->a*$this->b;
echo”multiplication of two parameters”.$sum;
}
}
$obj=new xyz();
$obj->cal(5,2);
?>
Function Overloading using function __call :

<?Php

Class Test12

{

Public Function __call($Name, $Arguments)

{

If ($Name === ‘Test’){

If(Count($Arguments) === 1 ){

Return $This->Test1($Arguments[0]);

}

If(Count($Arguments) === 2){

Return $This->Test2($Arguments[0], $Arguments[1]);

}

If(Count($Arguments) === 3){

Return $This->Test3($Arguments[0], $Arguments[1],$Arguments[2]);

}

}

}

Private Function Test1($Data1)

{

Echo $Data1;

}

Private Function Test2($Data1,$Data2)

{

Echo $Data1.’ ‘.$Data2;

}

Private Function Test3($Data1,$Data2,$Data3)

{

Echo $Data1.’ ‘.$Data2.$Data3;

}

}

$Test = New Test12();

$Test->Test(‘One Argument’); //Echoes “One Argument”

$Test->Test(‘Two’,’Arguments’);

$Test->Test(‘Three’,’Om’,’Test’); //Echoes “Two Arguments”

?>