That's not really "twice", because "=&" is different operator from
"=" (or, in other words, "=&" is really operator, not "&"). So you telling
the function "return reference" and you telling the assignment "assign
reference".
????
following you logic php currently does...
a) function test() { $ftest='x'; return $ftest; }
1) $xtest = test();
// function returns a copy of $ftest, copy is copied to $xtest (2x copy)
2) $xtest = &test();
// function returns a copy of $ftest, copy is aliased to $xtest
// (1x copy)
b) function &test() { $ftest='x'; return $ftest; }
1) $xtest = test();
// function returns a reference to $ftest, it is copied to $ftest
// (1x copy)
2) $xtest = &test();
// function returns a reference to $ftest, reference is aliased to
// $xtest (no copy)
haven written this, it makes sense (a bit), but it would make the & sign in function-names superfluous if it´s assigned afterwards (outside) and I assume that it´s the case frequently
Me (and perhaps a big bunch of other users), I thought it would sufficient to add the & sign to the function, what makes sense.
You *could* think that
<? function &test() { $y='y'; return $y; }
$x=test(); ?>
equals
<? $y='y';
$x=&$y; ?>
*If* that´s not the case we should document it thoroughly! Regarding from the users POV it *is* twice, because (a2) and (b1) are the same.
regards
--
o----------0-¬---------O-·---¬----o---®-----o o O ° .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ °
·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ °
o © ° . ·
| psychedelic experience | gott@kiffen.de | O ° o °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·