【发布时间】:2014-04-30 19:55:01
【问题描述】:
我使用多个服务器来获取数据,但是当我连接到特定的服务器时,PHP 丢失了语言环境配置。
所以我提取数据并格式化货币数字,但是在进程的过程中,如果它连接到该服务器,那么该过程的其余部分将不再格式化货币数字...... money_format() 命令
localeconv();
之前
Array
(
[decimal_point] => .
[thousands_sep] =>
[int_curr_symbol] => USD
[currency_symbol] => $
[mon_decimal_point] => .
[mon_thousands_sep] => ,
[positive_sign] =>
[negative_sign] => -
[int_frac_digits] => 2
[frac_digits] => 2
[p_cs_precedes] => 1
[p_sep_by_space] => 0
[n_cs_precedes] => 1
[n_sep_by_space] => 0
[p_sign_posn] => 1
[n_sign_posn] => 1
[grouping] => Array
(
)
[mon_grouping] => Array
(
[0] => 3
[1] => 3
)
)
之后
Array
(
[decimal_point] => .
[thousands_sep] =>
[int_curr_symbol] =>
[currency_symbol] =>
[mon_decimal_point] =>
[mon_thousands_sep] =>
[positive_sign] =>
[negative_sign] =>
[int_frac_digits] => 127
[frac_digits] => 127
[p_cs_precedes] => 127
[p_sep_by_space] => 127
[n_cs_precedes] => 127
[n_sep_by_space] => 127
[p_sign_posn] => 127
[n_sign_posn] => 127
[grouping] => Array
(
)
[mon_grouping] => Array
(
)
)
这是我运行的脚本:
<?PHP
//set locale information
setlocale( LC_MONETARY,'en_US' );
//print location information
print_r(localeconv());
// Array
// (
// [decimal_point] => .
// [thousands_sep] =>
// [int_curr_symbol] => USD
// [currency_symbol] => $
// [mon_decimal_point] => .
// [mon_thousands_sep] => ,
// ...
// )
//************************************************
//create conenction to server
$connection= new PDO("odbc:server", 'username', 'password');
//************************************************
//see locale information after creating a connection
print_r(localeconv());
// Array
// (
// [decimal_point] => .
// [thousands_sep] =>
// [int_curr_symbol] =>
// [currency_symbol] =>
// [mon_decimal_point] =>
// [mon_thousands_sep] =>
// ...
//
// )
?>
怎么会这样???? 谢谢
【问题讨论】:
-
我看到我已经在 2 年前发布了这个类似的问题,但是我们现在有几个月的新服务器,但仍然遇到这个问题。 stackoverflow.com/questions/12921059/…
-
我做了一些测试,如果我在浏览器中运行脚本,它会丢失配置,但如果我在 linux 命令行中运行它,它会保留配置,
-
我们在 LAMP 环境中
标签: php setlocale money-format localeconv