我有一个包含这个的数组
"postage_cost" => $customer[total_shipping_cost]
Run Code Online (Sandbox Code Playgroud)
当我用var_dump我得到
["postage_cost"]=>
string(5) "34.54"
Run Code Online (Sandbox Code Playgroud)
在制作数组时如何声明这是一个float而不是一个字符串?我将此数组发送到Web服务,我担心可能会出现一些数据类型混淆.$ customer结果来自MySQL请求.
我正在编写代码来显示某些产品的价格.如果价格为0则不显示任何内容.
<? if ($book->price_euro != 0) {$europrice = number_format($book->price_eur, 2); echo "€$europrice";}?>
<? if ($book->price_gbp != 0) {$gbpprice = number_format($book->price_gbp, 2); echo "£$gbpprice";}?>
<? if ($book->price_usd != 0) {$usdprice = number_format($book->price_usd, 2); echo "$$usdprice";}?>
Run Code Online (Sandbox Code Playgroud)
这回应"€0.00£33.00 $ 66.00".€价格设置为99.我认为没有任何理由认为这应该为0!难道我做错了什么?语法不好?