php底层变量分析

时间:2021-08-09 12:59:32
 <?php

 //数组引用
$arr = array('a','b','c','d');
$x = & $arr[1];
$tmp = $arr;
$arr[1] = 'e';
echo $tmp[1]; //e //数组指针
$arr = array('a','b','c','d');
foreach($arr as $key => $val){
}
var_dump(current($arr)); //boolean false foreach($arr as $key => $val){
$arr[$key]=$val;
}
var_dump(current($arr)); //b /*Array
(
[0] => a
[1] => b
[2] => c
[3] => a
)
Array
(
[0] => a
[1] => b
[2] => c
[3] => b
)
Array
(
[0] => a
[1] => b
[2] => c
[3] => c
)
Array
(
[0] => a
[1] => b
[2] => c
[3] => c
)*/
foreach($arr as &$v){
} foreach($arr as $v){
print_r($arr);
}