Is there a rational explanation for this PHP call-by-value behavior? Or PHP bug?
问题 PHP 5.5.12. Consider this: <?php $a = [ 'a', 'b', 'c' ]; foreach($a as &$x) { $x .= 'q'; } print_r($a); This, as expected, outputs: Array ( [0] => aq [1] => bq [2] => cq ) Now consider: <?php $a = [ 'a', 'b', 'c' ]; foreach(z($a) as &$x) { $x .= 'q'; } print_r($a); function z($a) { return $a; } This outputs: Array ( [0] => aq [1] => bq [2] => cq ) (!) But wait a minute. $a is not being passed by reference. Which means I should be getting a copy back from z(), which would be modified, and $a