For more information about ++ and & amp;, this post was last edited by yinjie_1984 from 2014-11-1508: 22: 22 & lt ;? Php $ a1; $ B & $ a; $ B $ a ++; the second sentence of $ a and $ B means that B points to the address of; the third sentence means adding 1 to the value of a after use, so $ b1; the key is that I don't know about ++ and & a little doubt.
This post was last edited by yinjie_1984 at 08:22:22
$ A = 1;
$ B = & $;
$ B = $ a ++;
// Calculate $ a and $ B
In the second sentence, B also points to the address of;
In the third sentence, the value of a is added with 1, so $ B = 1;
The key is that I don't know $ a ++ later. I don't mean to add 1 after using it, so now $ a = 2;
But the address of $ B is the same as the address of a. isn't the address of $ B equal to 2? Or is $ a ++ not executed in the third sentence? The answer to this question is $ a and $ B is 1;
For example
$ A = 1;
$ B = $ a ++;
?>
This is not $ B = 1, $ a = 2
A little dizzy...
------ Solution ----------------------
$a = 1;
$b = $a++;
var_dump($a, $b);
/*
int(2)
int(1)
*/
$a = 1;
$b = &$a;
$a++;
var_dump($a, $b);
/*
int(2)
int(2)
*/
$a = 1;
$b = &$a;
$b = $a++;
var_dump($a, $b);
/*
int(1)
int(1)
*/
For $ B = $ a ++;
Assign the value 1 of $ a to $ B, but the priority of ++ is higher than =, so the value is not assigned first, but ++, therefore, the value of $ a is 2 (because $ B is a reference of $ a, the value of $ B is also 2)
Then assign a value. The value of $ B is equal to 1.
Because $ B is a reference of $ a, $ a is changed back to 1.