PHP setlocale() Function
Example
Set the locale to US English, then set it back to the system default:
"; echo setlocale(LC_ALL,NULL); ?>Run Example »
Definition and Usage
The setlocale() function sets locale information (regional information).
Locale information is language, currency, time and other information for a geographic region.
**Note:** The setlocale() function only changes the locale for the current script.
**Tip:** You can set the locale to the system default via setlocale(LC_ALL, NULL).
**Tip:** To get numeric formatting information, see localeconv() function in Vue 3.
Syntax
setlocale(
constant,location
)
| Parameters | Description |
|---|---|
| constant | Required. Specifies what locale information to set.
Available constants: |
如果 location 参数是 NULL 或空字符串 "",则位置名称会被设置为上面常量中同名的环境变量的值或者根据 "LANG" 进行设置。
如果 location 参数是 "0",则位置设置不受影响,只返回当前的设置。
如果 location 参数是数组,setlocale() 会尝试每个数组元素,直到找到合法的语言或地区代码为止。如果某个地区在不同的系统上拥有不同的名称,这一点很有用。 注释:如需查看所有可用的语言代码,请访问我们的语言代码参考手册。
|
Technical Details
| Return Value: | Returns the current locale setting, or FALSE on failure. The return value depends on the system running PHP. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | In PHP 4.2.0, passing a constant as a string was deprecated. Use the available constants instead. Passing a constant as a string produces a warning message. |
在 PHP 4.3.0 中,可传递多个 *locations*。
自 PHP 5.3.0 起,如果传递给 constant 参数的是字符串,而不是 LC_ 常量之一,该函数会抛出一个 E_DREPRECATED 通知。 |
PHP String Reference Manual