Call by reference in php OOP
<?php
class a{
public function calc(&$a,&$b){
return $a+$b;
}
}
$obj = new a();
$v1=2;
$v2=4;
echo $obj->calc($v1,$v2);
?>
When you will pass value by reference then remember you must have to use '&' sing in parameter with variable as like as the example given up.
class a{
public function calc(&$a,&$b){
return $a+$b;
}
}
$obj = new a();
$v1=2;
$v2=4;
echo $obj->calc($v1,$v2);
?>
When you will pass value by reference then remember you must have to use '&' sing in parameter with variable as like as the example given up.
Comments
Post a Comment