A parameter passage by value – value of a variable is passed.
$b = 1;
function a($c) {
$c = 2; // modifying this doesn't change the value of $b, since only the value was passed to $c.
}
a($b);
echo $b; // still outputs 1
A parameter pass by reference? – a pointer to a variable is passed.
$b = 1;
function a($c) {
$c = 2; // modifying this also changes the value of $b, since variable $c points to it
}
a($b);
echo $b; // outputs 2 now after calling a();
solved PHP parameter variable vs reference [duplicate]