更好的向自身添加数字的方法? [英] Better way to add number to itself?

查看:108
本文介绍了更好的向自身添加数字的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中是否有更好/更短的方法

Is there a better/shorter way in PHP of doing

$x = $x + 10;

类似

$x .= 10; // (but this doesn't add together)

我确定我看到的方法比$x = $x + 10;

I am sure i've seen a shorter way than doing $x = $x + 10;

推荐答案

看看: http://php.net/manual/language.operators.assignment.php (在代码示例和注释中)

Have a look at: http://php.net/manual/language.operators.assignment.php (in the code examples and comments)

您可以使用:

$x += 10;

例如.

这篇关于更好的向自身添加数字的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆