Okay I think I am partially understanding.
Thats cool JohnJokes, I hope that thing is automated
I don’t see the point in doing a Reference Function, when the first example below does the same thing and it’s easier to read.
# EXAMPLE 1
$something = 200;
/** This sets $something even without a return */
function Blah(&$var)
{
$var = $var + 10;
}
Blah($something);
echo $something; // OUTPUT = 210
# EXAMPLE 2
/** This sets $something but a return
is required if its a Reference Function */
function &Yeah(&$var)
{
return $var = $var + 50;
}
echo '<br />';
Yeah($something);
echo $something; // OUTPUT = 260
It doesn’t add 2, I suspect that you are calling ref($b) and ref($d), which both point to $a so $a will be incremented twice.
return $val++; won’t give you an error, the difference is that if $val = 200, with ++$val the function will return 201, but with $val++ the function will return $200 and then set $val to 201.