簡體   English   中英

使用smarty模板系統在PHP中添加美元金額?

[英]Adding dollar amounts in PHP with smarty template system?

我有幾美元需要補充。 這是我當前正在使用的代碼:

{php}$totalaffamount = $pendingcommissions + $balance + $withdrawn;
echo $totalaffamount;{/php}

這是每個的值:

$pendingcommissions = $5.00 USD
$balance = $1000.00 USD
$withdrawn = $393.99 USD

我想這樣顯示總數:

$1398.99

但是,我一直猜測輸出為0 ,這是因為變量中存在美元符號和USD。有人知道我需要更改代碼才能使其正常工作嗎?

嘗試僅為此使用值,使用$符號不是加總的正確方法

$pendingcommissions = 5.00;
$balance = 1000.00;
$withdrawn = 393.99;

$total = $pendingcommissions + $balance + $withdrawn;

echo '$'.$total;

:)

暫無
暫無

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

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