$b =1; $a=&$b; $a=100; echo $a;//100 echo $b;//100 $c=1; $d=&$c; $d=200; echo $c;//200 echo $d;//200 //引用就是使用同一个内存地址(引用之间的变量相当于别名) $array = [1, 2, 3]; foreach ($array as $key => &$val) { //$val=array[$key]; $val+=1;//相当于array[$key]+=1; print_r($array); } print_r($array);//[2,3,4] $arr = [1,2,4]; foreach($arr as &$a){ $a = $a*$a; print_r($a);//1-4-16 } print_r($arr);//[1,4,16] foreach($arr as $a){ print_r($a);//1-4-4 }