0
How this code works?
<?php $a = '1'; $b = &$a; $b = "2$b"; echo "$a , $b"; ?> Its printing 21 , 21. How?
4 Respostas
+ 3
& - is passing by reference. So, in this case variable $b contain address of $a, but not it's value. When you are change value of $b - really you change value of $a.
+ 3
its 10
add 7 and 3
+ 1
Oh I get it. So $b is actually copy of $a because it points same address. Thanks.
0
on row 3 "2$b" you just concatenate/merge the two values. at the moment $b = 1 -> 21