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.

Comments

Popular posts from this blog

Git post receive setup at server for git push to the production from local machine