升级到 PHP-7.4,小数点分隔符问题

时间:2021-05-26 13:37:31

标签: php-7.4 localeconv

我正在尝试将本地机器上的 php7.2 升级到 php7.4。 我注意到 localeconv() 函数从每个版本返回不同的值。

PHP7.2 输出:

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
        (
        )

)

PHP7.4 输出:

Array
(
    [decimal_point] => .
    [thousands_sep] => ,
    [int_curr_symbol] => EUR 
    [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] => 1
    [n_cs_precedes] => 1
    [n_sep_by_space] => 1
    [p_sign_posn] => 1
    [n_sign_posn] => 1
    [grouping] => Array
        (
            [0] => 3
            [1] => 3
        )

    [mon_grouping] => Array
        (
            [0] => 3
            [1] => 3
        )

)

我没有找到任何php配置来设置小数点分隔符的默认值,我知道存在number_format()函数,但我需要全局设置。

我以为我改错了一些配置,所以我删除并重新安装了PHP7.4,但输出还是一样。

我也用 PHP8.0 试过,结果和 PHP7.2 一样

此时我检查了我的生产服务器,所有版本(7.2、7.4、8.0)都有相同的输出。

我想我的本地机器上有一些 PHP7.4 的配置,但我找不到在哪里以及如何更改它。

问题仅在于我在控制台中运行脚本时:php test.php,当我使用 nginx 和 php7.4-fpm 对其进行测试时,我得到与 7.2 相同的结果。

test.php:

<?php
    print_r(localeconv());

PHP7.4 从哪里获取语言环境配置,为什么与 PHP7.2 不同? 我必须检查什么?

0 个答案:

没有答案