+ 3
Why '&' is used with $a.
$a=5 $b=&$a $b=10 //Then what is the value of $a,and why??
3 Antworten
+ 5
& is a reference operator. That means if variable b is referencing var a, so the value of b will change the value of a.
If b = 10, then a will also initialize with 10.
Try in PHP compiler.
+ 3
Here$a=10 but why? please explain
+ 3
The & is used to obtain address of a variable, in this case address of variable <$a>. When we assign address of variable <$a> into variable <$b> we are telling variable <$b> to refer to and use the same address that is used by variable <$a>. This is why changes to variable <$b> will reflect on variable <$a>, voce versa.
Hth, cmiiw