【问题标题】:PHP > Zend Framework > Zend_MoneyPHP > Zend 框架 > Zend_Money
【发布时间】:2011-03-20 04:34:23
【问题描述】:

我使用 Zend_Money 来格式化货币如下

$currency = new Zend_Currency(array('value' => $money,
                                    'currency' => 'CAN', 
                                    'format' => 'fr'));

// output -> 100,00 $

在我的本地开发系统上正常显示(Windows 上的 wamp)

但是当我把它放在我的测试服务器上时(windows上的apache(不是我的选择,我不能改变它:()),代码输出变成了

// output -> 100,00 €

我想知道是否有人遇到过此类问题以及我需要在哪里寻找解决方案

谢谢

【问题讨论】:

    标签: php zend-framework currency


    【解决方案1】:

    Zend_Currency 是区域感知的。尝试传入'locale' => 'fr' 看看是否有影响:

    locale:定义此货币的区域设置。当省略其他设置时,它将用于检测默认值。请注意,如果您自己不设置语言环境,则会自动检测到它,这可能会导致问题。

    【讨论】:

      【解决方案2】:

      非常感谢它与我选择的解决方案方向相同。我在配置文件中添加了一个新密钥

      variable.locale = "fr_CA"
      

      然后在引导程序中将其作为整个应用程序的全局语言环境启动

      protected function _initLocale(){
          $variables = Zend_Registry::get('config')->variable;
          $locale = new Zend_Locale($variables->locale);
          Zend_Registry::set('Zend_Locale', $locale);
      }
      

      我已经有一个从引导程序中的先前方法启动的配置密钥

      【讨论】:

        猜你喜欢
        • 2010-11-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多