Php locale configuration in php.ini

前端 未结 3 841
無奈伤痛
無奈伤痛 2020-12-20 15:39

Can a default locale value be places in php.ini or .htaccess ?

The equivalent of the php function

   setlocale(LC_MONETARY, \'it_IT\');
相关标签:
3条回答
  • 2020-12-20 16:04

    It can, take a look at intl.default_locale.

    0 讨论(0)
  • 2020-12-20 16:18

    Sadly there is no way at this time to set this configuration PHP wide. I've been looking at the code and the ENV method doesn't work since LC_* variables are not treated like the other ones.

    You can patch PHP to use your locale instead of the default 'C' one or make a module if you really need to.

    But the actual way to go is to do it at the script level.

    EDIT: using auto_prepend_file in php.ini lets you run add some code before any script executed, so it looks like a nice place to use setlocale.

    0 讨论(0)
  • 2020-12-20 16:22

    There's nothing in the php.ini to help you. But as alternative you could try setting environment variables from .htaccess

    SetEnv   LC_ALL  it_IT.UTF-8
    

    But these settings only take effect for CGI and FastCGI versions of PHP at best, not for the usual mod_php installation.

    0 讨论(0)
提交回复
热议问题