所以我试图将时间字符串转换为"X秒前",但遇到了这个问题:
while($row = mysql_fetch_array($result))
<a href="#Profile"><class="profilep" id="postp" /></a>
<ul>
<li class="userName"></li>
<li class="distance"></li>
</ul>
<div class="time">
'.
$eventTime = $row['time'];
$age = time() - strtotime($eventTime);
echo $age "ago"
.'
</div></div>
<p align="justify"></p>
</div>
</article>';
循环不仅加载$age,还加载$row['time']。我想知道为什么会发生这种情况,以及如何解决?谢谢你抽出时间来帮助我学习。
串联似乎完全错误。先进行计算,然后创建输出。下次,请附上正确的代码。
while($row = mysql_fetch_array($result)) {
$eventTime = $row['time'];
$age = time() - strtotime($eventTime);
// Here is probably something missing.
echo '
<a href="#Profile"><[what tag should go here?] class="profilep" id="postp" /></a>
<ul>
<li class="userName"></li>
<li class="distance"></li>
</ul>
<div class="time">' . $age . ' seconds ago</div>
</div>
<p align="justify"></p>
</div>
</article>';
}