php & 引用和 变量赋值的区别
// php & 引用赋值 case $test_arr = array ("test_one", "test_two", "test_three" );$test_arr_refer =& $test_arr;
var_dump($test_arr);//赋值前原数组信息
$test_arr_refer = "test_one_new";
var_dump($test_arr);//赋值后test_arr数组信息
var_dump($test_arr_refer);//赋值后原数组信息
//赋值前原数组信息
array(3) {
=>
string(8) "test_one"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
//赋值后test_arr数组信息
array(3) {
=>
string(12) "test_one_new"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
//赋值后原数组信息
array(3) {
=>
string(12) "test_one_new"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
总结:php & 使用,一个变量赋值给另一个变量的数值,也具有其支配权力,即一个变量的别名。
// php 变量赋值 case
$test_arr = array ("test_one", "test_two", "test_three" );
$test_arr_normal = $test_arr;
var_dump($test_arr);//赋值前原数组信息
$test_arr_normal = "test_one_new";
var_dump($test_arr);//赋值后test_arr数组信息
var_dump($test_arr_normal);//赋值后原数组信息
//赋值前原数组信息
array(3) {
=>
string(8) "test_one"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
//赋值后test_arr数组信息
array(3) {
=>
string(8) "test_one"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
// php 变量赋值 case
$test_arr = array ("test_one", "test_two", "test_three" );
$test_arr_normal = $test_arr;
var_dump($test_arr);//赋值前原数组信息
$test_arr_normal = "test_one_new";
var_dump($test_arr);//赋值后test_arr数组信息
var_dump($test_arr_normal);//赋值后原数组信息
//赋值前原数组信息
array(3) {
=>
string(8) "test_one"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
//赋值后test_arr数组信息
array(3) {
=>
string(8) "test_one"
=>
string(8) "test_two"
=>
string(10) "test_three"
}
总结:php 变量赋值 使用,一个变量赋值给另一个变量的数值,不具有对其支配权力,只能对新增加的有支配的权力。
页:
[1]