|

YunVN网友
发表于 2018-12-24 10:51:40
|阅读模式
// php & 引用赋值 case $test_arr = array ("test_one", "test_two", "test_three" );
$test_arr_refer =& $test_arr;
var_dump($test_arr);//赋值前原数组信息
$test_arr_refer[0] = "test_one_new";
var_dump($test_arr);//赋值后test_arr数组信息
var_dump($test_arr_refer);//赋值后原数组信息
//赋值前原数组信息
array(3) {
[0]=>
string(8) "test_one"
[1]=>
string(8) "test_two"
[2]=>
string(10) "test_three"
}
//赋值后test_arr数组信息
array(3) {
[0]=>
string(12) "test_one_new"
[1]=>
string(8) "test_two"
[2]=>
string(10) "test_three"
}
//赋值后原数组信息
array(3) {
[0]=>
string(12) "test_one_new"
[1]=>
string(8) "test_two"
[2]=>
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[0] = "test_one_new";
var_dump($test_arr);//赋值后test_arr数组信息
var_dump($test_arr_normal);//赋值后原数组信息
//赋值前原数组信息
array(3) {
[0]=>
string(8) "test_one"
[1]=>
string(8) "test_two"
[2]=>
string(10) "test_three"
}
//赋值后test_arr数组信息
array(3) {
[0]=>
string(8) "test_one"
[1]=>
string(8) "test_two"
[2]=>
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[0] = "test_one_new";
var_dump($test_arr);//赋值后test_arr数组信息
var_dump($test_arr_normal);//赋值后原数组信息
//赋值前原数组信息
array(3) {
[0]=>
string(8) "test_one"
[1]=>
string(8) "test_two"
[2]=>
string(10) "test_three"
}
//赋值后test_arr数组信息
array(3) {
[0]=>
string(8) "test_one"
[1]=>
string(8) "test_two"
[2]=>
string(10) "test_three"
}
总结:php 变量赋值 使用,一个变量赋值给另一个变量的数值,不具有对其支配权力,只能对新增加的有支配的权力。
|
|
|
|
|
|
|