Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $a=5;
- $b=&$a;
- $a=8;
- echo $b;
- // prints 8
- $a=5;
- $b=$a; //no &
- $a=8;
- echo $b;
- // prints 5
- php > $a=5;
- php > $b=&$a;
- php > $a=8;
- php > echo $b;
- 8
- php > // prints 8
- php > $a=5;
- php > $b=$a; //no &
- php > $a=8;
- php > echo $b;
- 8
- php > // prints 5
- php > $b=3;
- php > echo $a;
- 3
- php > $e=5; $f=$e; $e=6; echo $f;
- 5
- $a = 5; // creates a "slot", puts 5 in it, makes $a point to it
- $b =& $a; // makes $b point to the same "slot" $a points to
- $c = 6; // creates a "slot", puts 6 in it, makes $c point to it
- $a = $c; // puts the value of the slot $c points to into the slot $a points to
- echo $b; // outputs the value of the slot $b points to (6)
- $b = $a
- $value = 5;
- $alias = &$value;
- $value = 8;
- echo $alias; # 8
- $value = 5;
- $alias = $value; # no &
- $value = 8;
- echo $alias; # 8 (OP expected 5)
- $alias = $value; # no &
- $value = $value;
- $alias = &$other;
- unset($alias);
Add Comment
Please, Sign In to add comment