Value passing is to assign the value of a real parameter to a row parameter, so the modification of the row parameter does not affect the value passing address of the real parameter. it is a special way to pass the value, it only transmits the address. after the address is not passed as an int, both the real parameter and the row parameter point to the same object and pass the reference to the real location... syntaxHighlighter. all ();
Pass value,
Is to assign the value of the real parameter to the row parameter
The modification of the row parameter does not affect the value of the real parameter.
Transfer address
It is a special method for transferring values, but it only transmits an address, not a common such as int
After the address is passed, both the real parameter and the row parameter point to the same object.
Upload reference
Actually passing parameters in address mode
After passing, the row parameters and real parameters are the same object, but their names are different.
Modifying the row parameter will affect the value of the real parameter.
Bytes -----------------------------------------------------------------------------------
I think it is better to understand function calls.
Pass value:
The parameter stack is a copy of the parameter.
Any modification works on the copy and does not work on the original variable.
Pass pointer:
The stack is a copy of the pointer variable.
When you perform pointer decoding, the value of the pointer points to the original variable. Therefore, you can perform operations on the original variable.
Reference:
The stack is a referenced copy. Because the reference is directed to a variable, the reference operation is actually the operation of the variable to which it points. (The function is the same as passing a pointer, but referencing a grass paper with little knowledge of the pointer)
Bytes -----------------------------------------------------------------------------------
Basic theory of function parameter transfer mechanism
In essence, the function parameter transfer mechanism is a problem where the call function (process) and the called function (process) communicate when the call occurs. There are two basic parameter transfer mechanisms: value transfer and reference transfer. The following describes the functions that call other functions as the main functions. the called functions are called functions.
In the passl-by-value process, the formal parameters of the called function are processed as local variables of the called function, that is, the memory space is opened in the stack to store the values of the real parameters put in by the main function, thus becoming a copy of the real parameters. The feature of value transfer is that any operation of the form parameter of the called function is performed as a local variable, without affecting the value of the real parameter variable of the main function.
During the pass-by-reference process, the form parameter of the called function opens up the memory space in the stack as a local variable, however, the address of the real variable put in by the main function is stored. Any operation of the called function on the form parameter is processed as indirect addressing. that is, the address stored in the stack is used to access the real variable in the main function. Because of this, any operation performed by the called function on the form parameter affects
Real variable.
Bytes -----------------------------------------------------------------------------------
We will only discuss the value transfer and reference:
The so-called value transfer means that only passing the object value to the target object is equivalent to copy; the system will re-open a completely identical memory space for the target object.
The so-called reference means passing the address of the object in the memory to the target object is equivalent to making the target object and the original object correspond to the same memory bucket. At this time, if you modify the target object, the data in the memory will also change.
$ A = 'C ';
$ B = & $ a; // indicates that $ B and $ a reference the same variable.
$ A = 'abc'; // $ a is reset here.
Echo $ B; // returns abc
Unset ($ a); // cancel the reference
Echo $ B; // abc is still output here
$ A = 'abc ';
Echo $ B; // The abc is still output because the reference has been canceled.