簡體   English   中英

在 PHP 中添加返回字符串添加。 10+12=1012!!! 我需要 10+12=22

[英]Adding in PHP returns string addition. 10+12=1012!!!! I need 10+12=22

我的代碼:

$gettotz=0;
while($mycartqry=mysqli_fetch_array($cartqry)){
                    $one=$mycartqry['nos'];
                    $two=$gettotz;
                echo $gettotz.=$myVar+$myVar2;
            }

db viz 中有兩個值,即 10 和 12。我的答案是 01012。我的答案應該是 22...請幫助

應該是這樣的:

$gettotz=0;
while ($mycartqry=mysqli_fetch_array($cartqry)){
    $one = $mycartqry['nos'];
    $gettotz += $one;
    // what is `$myVar` and `$myVar2` is unclear
    // but if they exists you can also add'em:
    // $gettotz += $one + $myVar + $myVar2;
}
echo $gettotz;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM