When a function is called, it is modified in the function by assigning the PHP array as an argument to the parameter, without affecting the array itself.
Note that the pass in this procedure 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 parameter is a copy of an array.
This is different from some other languages (such as C, JS, etc.) is not the same, it is worth noting!
Copy CodeThe 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:
Copy CodeThe 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"]
http://www.bkjia.com/PHPjc/326508.html www.bkjia.com true http://www.bkjia.com/PHPjc/326508.html techarticle when a function is called, it is modified in the function by assigning the PHP array as an argument to the parameter, without affecting the array itself. Note that the pass in this procedure is passed as a value, and the array variable does not refer to ...