English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Character String Functions Manual
The setlocale() function is used to set region information.
string setlocale ( int $category , array $locale )
Used to set region information
Returns the new current region information. If the region setting feature is not implemented on your platform, the specified region setting does not exist, or the category name is invalid, it will return false.
Serial Number | Parameter and Description |
---|---|
1 | constant Specify what region information should be set.Available Constants:
|
2 | location Specify the country to set the region information to/Region. It can be a string or an array. Multiple locations can be passed.If the location parameter is NULL or an empty string "", the location name will be set to the value of the environment variable with the same name as the constant above or set according to "LANG". If the location parameter is "0", the location setting is not affected, and only the current setting is returned. If the location parameter is an array, setlocale() will try each array element until a valid language or region code is found. This is useful if a region has different names on different systems. |
In PHP 4.2.0, passing constants as strings is deprecated. Please use the available constants instead. Passing constants as strings will produce a warning message.
In PHP 4.3.0, multiple locations can be passed.
Since PHP 5.3Starting from version .0, if the constant parameter is a string rather than one of the LC_ constants, the function will throw an E_DEPRECATED notice.
Try the following example, set the region to UK, and then set it back to system default:
<?php //Set region to UK echo setlocale(LC_ALL, "UK"); echo "<br>"; //Set back to system default echo setlocale(LC_ALL, NULL); ?>Test and see‹/›
Output Result
C