Okay another referencing Question, not exactly sure how to google this one so I'll ask it here:
$TempArray = array_merge( array("FILLER"),
&$this->Variable1,
&$this->Variable2,
&$this->Variable3);
(variable1-3 are classes)
would editing the classes stored in that array, edit the referenced classes? Or is this not possible.
It is not possible in this case.
Reference &
should and may be specified only in function declaration , not when you call the function.
array_merge
creates a new array from the input values, so no, modification of $tempArray
will not modify any of the arrays which were used to create it.
You should also be getting a warning if you try to use &
when calling a method.
On the other hand, in this case:
$tmpArr = array();
$b = 0;
$tmpArr[0] = &$b;
$arr2 = array_merge( $tmpArr, array( 'a','b','c' ));
$arr2[ 0 ]++;
echo $b; // 1
Because you are storing the reference inside and array, when the reference is added to the result of array_merge, it is still a reference, so it still works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.