Assignment method 1 in variable 3 in php, passing value assignment, for example, $ a = 1, $ B = $ a, etc;
2. assign values by reference. for example, $ a = & $ B, that is, $ a and $ B both point to the same storage variable value address in the memory;
3. Reference counting and passing values. all objects in php and js use the default value passing method to reference counting and passing values. The example is as follows:
Class Dog {
Public $ name = "Xiaohua ";
Public $ leg = 4;
}
$ A = new Dog; // at this time, $ a points to an address in the memory (assuming 0 XFFAD [1]), and the address points to the value of the final object.
$ B = $ a; // at this time, both $ B and $ a point to another address in the memory (0 XFFAD [2]), and the address points to the value of the final object.
Var_dump ($ B-> leg); // The result is int 4.
$ B = 999;
Var_dump ($ B); // The result is an int 999;
Var_dump ($ a); // The result is not int 999, but object (Dog) [1].
Public 'name' => string 'character �� '(length = 6) public 'leg' => int 4
From this we can see that the object's value passing method is a little different from the second reference value passing method.