php - += 是做什么用的?

标签 php

我认为这是一个愚蠢的问题,但我无法在 php 上找到它。为什么下面代码中的+带=:

function calculateRanking()
{
    $created = $this->getCreated();

    $diff = $this->getTimeDifference($created, date('F d, Y h:i:s A'));

    $time = $diff['days'] * 24;
    $time += $diff['hours'];
    $time += ($diff['minutes'] / 60);
    $time += (($diff['seconds'] / 60)/60);

    $base = $time + 2;        

    $this->ranking = ($this->points - 1) / pow($base, 1.5);

    $this->save();
}

这是 $time 拥有所有这些值还是将所有值添加到 $time?

谢谢

最佳答案

它将所有这些值加到时间上。

something += somethingelse

的捷径
something = something + somethingelse

-亚当

关于php - += 是做什么用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/542995/

相关文章:

php - 表中不存在键列 'survey_type_id' 如何解决

php - 有没有办法在 PHP 中验证 SSH 公钥?

php - Laravel:如何显示配置?

php - whereBetween 与日期不起作用

php - 检查大量值在数据库中的唯一性

php - 获取所有带有使用权重的标签

php - 通知 : Undefined index: args

php - 从多个表复制数据并插入到一个表中?

php - 将值检索到数组中

php - Opencart 启用 SEO url 导致 404 错误