In this php code, why does the third echo $a become EFG,? in my understanding, echo $an is still ABC?

$a = "ABC";
$b = & $a;
echo $a br / here output: ABC
echo $b ABC / here output: ABC
$b = "EFG";
echo $a balance / the value of $a here changes to EFG so output EFG
echo $bash / here output EFG because it changes the same value.
? >

Php
May.25,2021

because you created a reference

$b = &$a 

at this point, a correspondence is created, which means that b and a share a piece of memory space. B changed, so a changed

.
& means reference in php $b = & $a; makes $b point to the same memory as $a , so changing the value an of b will also change


focus on the assignment statement $b = & $a; . $b actually points to the memory address of $a .
when you assign a value to $b , it actually changes the value of $a .
if your first assignment statement is $baked statements; , then assign a value to $b , and the value of $a will not be changed.


$b = & $a; is a reference assignment, where the variables $b and $a perform the same memory address.
when you modify $b, the value of $an is also modified.

https://codeshelper.com/a/11.


you can think of references as pointers. It points to a memory address, and the memory address is where your variables are stored

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32575-40e4a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32575-40e4a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?