1--TEST-- 2Pass same variable by ref and by value. 3--FILE-- 4<?php 5function valRef($x, &$y) { 6 var_dump($x, $y); 7 $x = 'changed.x'; 8 $y = 'changed.y'; 9} 10 11function refVal(&$x, $y) { 12 var_dump($x, $y); 13 $x = 'changed.x'; 14 $y = 'changed.y'; 15} 16 17 18echo "\n\n-- Val, Ref --\n"; 19$a = 'original.a'; 20valRef($a, $a); 21var_dump($a); 22 23echo "\n\n-- Ref, Val --\n"; 24$b = 'original.b'; 25refVal($b, $b); 26var_dump($b); 27?> 28--EXPECTF-- 29 30 31-- Val, Ref -- 32string(10) "original.a" 33string(10) "original.a" 34string(9) "changed.y" 35 36 37-- Ref, Val -- 38string(10) "original.b" 39string(10) "original.b" 40string(9) "changed.x" 41