我有以下代码:

$TargetPlayerPosition = $GLOBALS['DATABASE']->uniquequery("SELECT total_rank FROM ".STATPOINTS." WHERE `id_owner` = '". $this->_fleet['fleet_target_owner'] ."';");


问题是我不能将+10添加到$TargetPlayerPosition,因为它是字符串。但是在数据库中,total_rank是一个INT。

最佳答案

<?php
$TargetPlayerPosition = $GLOBALS['DATABASE']->uniquequery("SELECT total_rank FROM ".STATPOINTS." WHERE `id_owner` = '". $this->_fleet['fleet_target_owner'] ."';");
/* conversion to int */
$rank = (int) $TargetPlayerPosition;
/* do the required arithmetic */
/* $rank + 10 will work now */
?>

10-08 12:24