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