PHP program to demonstrate the call by reference parameter passing

bookmark

<?php
//PHP program to demonstrate call by 
//reference parameter passing
function Sum($num1, $num2, &$num3)
{
    $num3 = $num1 + $num2;

    echo "Inside function->num3: " . $num3 . "<br>";
}

$num1 = 10;
$num2 = 20;
$num3 = 0;

Sum($num1, $num2, $num3);
echo "Outside function->num3: " . $num3;
?>


Output
Inside function->num3: 30
Outside function->num3: 30