Passing simple types by reference can lead to confusion if the code being called is not in direct line of sight.
eg.
function test( &$a , &$b , $c )
{
$a = $a*c;
$b = $b*c;
}
$d = 1;
$e = 2;
$f = 3;
test( $d , $e , $f );
Unless you call the doc comment up when calling there is now way of knowing what is being affected. Could be any combination of $d, $e, $f. This confusion can lead to errors. If you are doing a referential change on simple types then make it clear in the function/method name.
eg.
function RefRecalculateXY( &$x , &$y , $c )
{
$x = $x*c;
$y = $y*c;
}
$width = 1;
$height = 2;
$multiplier = 3;
RefRecalculateXY( $width , $height , $multiplier );
So it is clear when looking at the code that you are breaking out of the norm and doing something different. Referencial recalculation is useful when dealing with large pieces of data to conserve memory.
Objects should be passed by reference manually in php4 so migration to 5 will ensure behavioural consistentancy.
"When should references be used?
When you're passing on large text, array or object structures to functions or passing data trough nested function calls. You should also perform benchmarking of your PHP code to find out places that need references, often using references will reduce execution time significantly.
When should references not be used?
When creating functions which usually is fed with constants values. PHP cannot create references to unassigned data, except for new object instances. For instance consider this example"
http://zez.org/article/articleprint/77/