3
I have the following code snippet:
$a = '1';
$b = &$a;
$b = "2$b";
echo $a.", ".$b;
Exit:
21, 21
I realized that there is no assignment to the variable $a
other than the fact that $b = &$a
using the &
, that in the end, the result is changed. I did not understand very well, so I question myself:
What does the &
for this situation? What would be the goal? And at what point is it used?
So that instead of using the value the variable manipulation use as "reference", ie when copying the value to another "variable" it will be possible to manipulate the original variable through the other (more or less this) :)
– Guilherme Nascimento
Related: https://answall.com/questions/51209/use_joint-operations-functions-em-php
– Wallace Maxters
The answers of the colleagues are great, I just suggest to read the documentation of Objects and references PHP, to clarify doubts.
– EASoares
@Wallacemaxters I can barely see your moves.
– Jéf Bueno
Related Reference of arguments may be injurious?
– Guilherme Nascimento