在PHP中有没有更好/更短的方式
$x = $x + 10;
Run Code Online (Sandbox Code Playgroud)
即
就像是
$x .= 10; // (but this doesn't add together)
Run Code Online (Sandbox Code Playgroud)
我相信我看到的方式比做得更短 $x = $x + 10;
Yos*_*shi 33
看看:http://php.net/manual/language.operators.assignment.php(在代码示例和注释中)
您可以使用:
$x += 10;
Run Code Online (Sandbox Code Playgroud)
例如.
Pee*_*Haa 13
$x += 10;
然而,有些人发现这更难阅读.
你尝试过的($x.= 10)仅适用于字符串.
例如
$x = 'test';
$x.= 'ing...';
Run Code Online (Sandbox Code Playgroud)