每次我尝试运行此代码时都会显示一条消息:
Fatal error: Call to undefined function money_format()
Run Code Online (Sandbox Code Playgroud)
有这个问题的线是:
$pricetotal = money_format("%10.2n", $pricetotal);
Run Code Online (Sandbox Code Playgroud)
和
$cartTotal = money_format("%10.2n", $cartTotal);
Run Code Online (Sandbox Code Playgroud)
你能解释一下这种情况发生的原因吗?
$cartOutput = "";
$cartTotal = "";
$pp_checkout_btn = '';
$product_id_array = '';
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
$cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>";
} else {
// Start PayPal Checkout Button
$pp_checkout_btn .= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="you@youremail.com">';
// Start the For Each loop
$i = 0; …Run Code Online (Sandbox Code Playgroud) 有没有办法得到像这样的字符串的浮点值:75,25 €除了parsefloat(str_replace(',', '.', $var))?
我希望这依赖于当前的网站语言,有时逗号可以用点替换.
为什么会出现此错误?
码:
setlocale(LC_MONETARY, "en_US");
$pricetotal = money_format("%10.2n", $pricetotal);
Run Code Online (Sandbox Code Playgroud)
服务器细节.
Apache Version : 2.2.21
PHP Version : 5.3.8
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Fatal error: Call to undefined function money_format()
Run Code Online (Sandbox Code Playgroud) 我已经读过money_format在Windows和某些Linux发行版(即BSD 4.11变体)上不可用.但我想使用普通函数编写跨平台库,如果可用,并在没有时使用此解决方法,因此我的库将能够在每个基于PHP的Web服务器上运行.
是否有任何简单的解决方案来检查内置功能是否可用以及是否包含上述解决方案?
各位大家好,感谢您的阅读.我想知道如何将数字格式化为货币或者只是简单地在最后添加€.我在yii框架的管理页面上的gridview中工作.我有这个例如
'columns'=>array(
'title',
array(
'name'=>'cost',
'value'=>'$data->cost',
)
Run Code Online (Sandbox Code Playgroud) php ×4
cart ×1
currency ×1
formatting ×1
money-format ×1
numbers ×1
parsing ×1
shopping ×1
yii ×1