PHP array transfer is to correct the concept of value transfer rather than reference transfer. When calling a function, you assign the PHP array as a real parameter to the form parameter. modifying the parameter in the function does not affect the array. It indicates that the value is passed during this process. the array variable does not mean to assign the PHP array as the real parameter to the form parameter when calling the function. modification in the function does not affect the array itself.
This process is passed as a value. The array variable is not a reference to the array itself. The PHP array itself exists as a value and the form parameter is a copy of the array.
This is very different from other languages (such as c and Js). it is worth noting!
The code is as follows:
$ Arr = array (
'Name' => 'corn ',
'Age' => '24 ',
);
Test_arr ($ arr );
Function test_arr ($ arr ){
$ Arr ['name'] = 'qqyumidi ';
}
Print_r ($ arr); // result: Array ([name] => corn [age] => 24)
The Js code is as follows:
The code is as follows:
Var arr = new Array ('corn', '24 ');
Test_arr (arr );
Function test_arr (arr ){
Arr [0] = 'qqyumidi ';
}
Console. log (arr); // result: ["qqyumidi", "24"]
Bytes. It indicates that the value is passed in this process, and the array variable does not mean...