Hello,
When the variable is passed as value then it is called pass variable by value.
Here, the main variable remains unchanged even when the passed variable changes.
Sample code:
function test($n) {
$n=$n+10;
}
$m=5;
test($m);
echo $m;
When the variable is passed as a reference then it is called pass variable by reference.
Here, both the main variable and the passed variable share the same memory location and & is used for reference.
So, if one variable changes then the other will also change.
Sample code:
function test(&$n) {
$n=$n+10;
}
$m=5;
test($m);
echo $m;
Thank You!