PHP setlocale() Function
PHP setlocale() Function
The setlocale() function in PHP sets locale information(language, monetary, time and, other information specific for a geographical area.)
Syntax
setlocale ( int $category , array $locale )
Parameter
category(required)- This parameter specified a named constant specifying the category of the functions affected by the locale setting. The constant list is as follow:
- LC_ALL- all of the below
- LC_COLLATE- for string comparison
- LC_CTYPE- for character classification and conversion
- LC_MONETARY- for localeconv()
- LC_NUMERIC- for decimal separator
- LC_TIME- for date and time formatting with strftime()
- LC_MESSAGES- for system responses
location(required)- This parameter specifies what country or region to set the locale information(string or an array). It is also possible to pass multiple locations.
Return
This function returns the new current locale, or FALSE if the specified locale functionality is not implemented on your platform, or if the locale does not exist or the category name is invalid.
Example 1
Output
The setlocale() function will return: en_US.UTF-8
Example 2
Output
The category LC_MESSAGES return: en_US.UTF-8 The category LC_CTYPE return:
Example 3
Output
The setlocale() function will return: