3

因此, localeconv() 似乎忽略了我的 php 脚本中的语言环境,并返回一个基本上为空的数组。

我发现了许多问题,等等,所有的答案都归结为没有为 Windows 正确设置的语言环境。

我相信这个脚本使用有效值设置它,并且我可以确认当前语言环境是我想要使用的语言环境,但无论当前语言环境是什么,localeconv() 只会返回相同的(大部分)空数组。

我希望看到的是 mon_decimal_point 和 mon_thousands_separator 值被填充了一些东西。

所以,我的问题是:

我该怎么做才能从 localeconv() 获得真正的结果?

示例脚本:

<?php
echo locale_get_default()."\n";
echo setlocale(LC_MONETARY, locale_get_default()) . "\n";
echo setlocale(LC_MONETARY, '0')."\n";

$locale_info = localeconv();
print_r($locale_info);

echo setlocale(LC_MONETARY, null) ."\n";
echo setlocale(LC_MONETARY, '0')."\n";

$locale_info = localeconv();
print_r($locale_info);

脚本输出:

sve
Swedish_Sweden.1252
Swedish_Sweden.1252
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
        (
        )

)
English_United States.1252
English_United States.1252
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
        (
        )

)
4

0 回答 0