Class member reference to another object in PHP
Get the solution ↓↓↓Solution:
The answer is actually quite simple. Yes, you pass the array by reference via&$array
but this reference gets lost when you assign/copy it to the member variable. To keep the reference, you can use the=&
operator like so
$this->arrayRef =& $array;
See it work in this fiddle. You can read more about it in this question/answer (just look for reference).
Beware not to use&=
(which does a bitwise operation) instead of=&
(which assigns by reference).
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the payload is invalid.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.