ZEND 货币符号显示 1 [英] ZEND currency symbol is displaying 1

查看:29
本文介绍了ZEND 货币符号显示 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 zend 货币来显示基于区域设置的货币.当我使用以下代码时,符号被 1 替换而不是简单地被删除:

I'm using zend currency to display the currency based on locale. When I use the following code the symbol gets replaced by 1 instead of simply being removed:

$currency = new Zend_Currency($locale);$currency->setFormat(array('symbol' => Zend_Currency::NO_SYMBOL));

$currency = new Zend_Currency($locale); $currency->setFormat(array('symbol' => Zend_Currency::NO_SYMBOL));

通常返回的是:€2.500,01但是在setFormat"调用之后我得到了这个:1 2.500,01

What normally gets returned is this: € 2.500,01 but after the "setFormat" call I'm getting this: 1 2.500,01

我不想要1"在那里.

关于如何解决这个问题有什么想法吗?

Any ideas on how to fix this?

谢谢.

推荐答案

您在 setFormat 中设置了错误的选项.您需要将display 设置为Zend_Currency::NO_SYMBOL.像这样:

You're setting the wrong option in setFormat. You need to set display to Zend_Currency::NO_SYMBOL. Like this:

$c = new Zend_Currency();
$c->setFormat(array('display' => Zend_Currency::NO_SYMBOL));
echo $c->toCurrency(2500.01);

哪些输出

2,500.01

您目前的做法是将符号设置为 1,因为这是常量 NO_SYMBOL 的计算结果.

The way you are currently doing it is literally setting the symbol to 1 because that's what the constant NO_SYMBOL evaluates to.

这篇关于ZEND 货币符号显示 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆