Pass the value and reference of php array objects to pass the general data type (int, float, bool) here we will introduce in detail the differences between the object of the array and the class as a parameter for passing values in the array & lt ;? Phpfunctionmain () {$ ccarray (a, B); change ($ cc); pass php array/object values and references
The general data types (int, float, bool) are not described in this regard.
Here we will introduce in detail the differences between the array and the class object passing values as parameters.
Array Value transfer
output:array(2) { [0]=> string(1) "a" [1]=> string(1) "b"}
Array reference transfer
outpout:array(1) { [0]=> string(2) "dd"}
Class object value transfer
ss = 10;}main();?>output:object(pp)#1 (1) { ["ss"]=> int(10)}
Class object reference transfer
ss = 10;}main();?>object(pp)#1 (1) { ["ss"]=> int(10)}
Summary: In php, an array is a common variable. Passing a value requires a copy of a real parameter, which is irrelevant to the real parameter. after passing a reference, the value of the real parameter can be changed.
The object of the class is a reference transfer for both value passing and reference passing. it is a reference to the object and changes the value of the real parameter.