i wonder where i should put the & properly.
$b =& $a;
or
$b = &$a;
i wonder where i should put the & properly.
$b =& $a;
or
$b = &$a;
Both reference the same thing, just a matter of coding style.
Personally, I prefer the $b = &$a
style for readability, the space from the &
and $
throws me off.
This is actually up to you.
I would, like most others, put the &
directly before the $
sign of the variable - it makes the code easier to read in my opinion.
Put it where the code convention you use tells you to put it.
The PHP manual on references uses =&
exclusively, whereas the PHP manual on variables states
To assign by reference, simply prepend an ampersand (&) to the beginning of the variable which is being assigned (the source variable).