开发者

PHP locale configuration in php.ini

开发者 https://www.devze.com 2023-02-12 06:45 出处:网络
Can a default locale value be placed in file php.ini or .htaccess? The equivalent of the PHP function setlocale(LC_开发者_运维技巧MONETARY, \'it_IT\');

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

The equivalent of the PHP function

setlocale(LC_开发者_运维技巧MONETARY, 'it_IT');

for example.


It can. Take a look at intl.default_locale.


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

SetEnv   LC_ALL  it_IT.UTF-8

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


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.

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

精彩评论

暂无评论...
验证码 换一张
取 消