php底层变量分析
1 <?php 2 3 4 //数组引用 5 $arr = array('a','b','c','d'); 6 $x = & $arr[1]; 7 $tmp = $arr; 8 $arr[1] = 'e'; 9 echo $tmp[1]; //e 10 11 //数组指针 12 $arr = array('a','b','c','d'); 13 foreach($arr as $key => $val){ 14 } 15 var_dump(current($arr)); //boolean false 16 17 foreach($arr as $key => $val){ 18 $arr[$key]=$val; 19 } 20 var_dump(current($arr)); //b 21 22 23 24 /*Array 25 ( 26 [0] => a 27 [1] => b 28 [2] => c 29 [3] => a 30 ) 31 Array 32 ( 33 [0] => a 34 [1] => b 35 [2] => c 36 [3] => b 37 ) 38 Array 39 ( 40 [0] => a 41 [1] => b 42 [2] => c 43 [3] => c 44 ) 45 Array 46 ( 47 [0] => a 48 [1] => b 49 [2] => c 50 [3] => c 51 )*/ 52 foreach($arr as &$v){ 53 } 54 55 foreach($arr as $v){ 56 print_r($arr); 57 }