Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP货币格式在不同的服务器上返回带/不带货币前缀的字符串_Php_Linux_Locale - Fatal编程技术网

PHP货币格式在不同的服务器上返回带/不带货币前缀的字符串

PHP货币格式在不同的服务器上返回带/不带货币前缀的字符串,php,linux,locale,Php,Linux,Locale,我的客户机有两台服务器,分别是临时服务器和实时服务器。它们有不同的PHP版本(我知道——它们就是这样提供的)。我有以下代码: setlocale(LC_MONETARY, 'en_GB'); $product = wc_get_product( $product_id ); if ($product->get_price()){ return (string) money_format('%i', $product->get_price()); } 在暂存服务器上,它返回如下

我的客户机有两台服务器,分别是临时服务器和实时服务器。它们有不同的PHP版本(我知道——它们就是这样提供的)。我有以下代码:

setlocale(LC_MONETARY, 'en_GB');
$product = wc_get_product( $product_id );
if ($product->get_price()){
   return (string) money_format('%i', $product->get_price());
}
在暂存服务器上,它返回如下格式的价格:“10.00英镑” 然而,在live上,它返回的价格没有英镑前缀,只有“10.00”

在两台服务器上运行时: 地区-a | grep en|u GB 我得到:

登台服务器在Linux版本2.6.32-696.18.7.el6.x8664上运行PHP 5.6.21(mockbuild@c1bl.rdu2.centos.org)(gcc版本4.4.7 20120313(Red Hat 4.4.7-18)(gcc))#1 SMP周四1月4日17:31:22 UTC 2018

Live在Linux版本4.9.96mtv23(ci)上运行PHP 5.3.28_slave@cislave73-git.mtsvc.net)(gcc版本4.7.2(Debian 4.7.2-5))#1 SMP周二5月15日14:22:40 PDT 2018

其他发现…
我现在发现,当从循环中多次调用此代码时(即,当我返回大量产品时),就会出现问题。如果在php脚本执行过程中只调用一次(返回单个产品),它就可以工作

应使用utf-8字符集设置区域设置:

setlocale(LC_MONETARY, 'en_GB.utf8');

对不起,我应该提一下,我试过了,没什么区别。
setlocale(LC_MONETARY, 'en_GB.utf8');