Home >Backend Development >PHP Tutorial >此代码运行后为何会输出5?

此代码运行后为何会输出5?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:20:45994browse

$a = 1;$b = &$a;$c = (++$a) + ($a++);var_dump($c);

为何会输出5?


回复讨论(解决方案)

$a = 1;
$b = &$a; //既然不用就不要定?了
$c = (++$a) + ($a++);
//$c=(2)+(2++)
var_dump($c);

不管是 ++$a ?是 $a++ ?是 $a+=1  ?於初?者你就??先理解? $a=$a+1 就好了
等你逐步深入之後再回?研究????法的不同之?.

$c = (++$a) + ($a++)=2+1;
前++,后++弄清楚了再玩这样复杂的

$c = (++$a) + ($a++);
$c = (++1) + ($a++);
$c = 2 + 2++;
$c = 2 + 3;
$c = 5;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn