Easy Tutorial
❮ Func Array Reset Php Intlchar ❯

PHP setlocale() Function

PHP String Reference Manual

Example

Set the locale to US English, then reset to the system default:


Definition and Usage

The setlocale() function sets the locale information (regional information).

Locale information includes language, currency, time, and other information for a geographical area.

Note: The setlocale() function only changes the locale information for the current script.

Tip: You can set the locale information to the system default by using setlocale(LC_ALL, NULL).

Tip: For numeric formatting information, see the localeconv() function.


Syntax

Parameter Description
constant Required. Specifies what locale information should be set. Available constants: LC_ALL - Includes all below options<br> LC_COLLATE - Sort order<br> LC_CTYPE - Character classification and conversion (e.g., all characters uppercase or lowercase)<br> LC_MESSAGES - System message format<br> LC_MONETARY - Currency format<br> LC_NUMERIC - Numeric format<br> LC_TIME - Date and time format
location Required. Specifies what country/region to set the locale information to. Can be a string or an array. Multiple locations can be passed. <br> <br> If the location parameter is NULL or an empty string "", the location name is set to the value of the environment variable of the same name as the constant above or based on "LANG". <br> <br> If the location parameter is "0", the location setting is not affected, only the current setting is returned. <br> <br> If the location parameter is an array, setlocale() will try each array element until it finds a valid language or region code. This is useful if a region has different names on different systems. Note: For a list of all available language codes, visit our language code reference manual.

Technical Details

Return Value: Returns the current locale setting, or FALSE if it fails. The return value depends on the system running PHP.
PHP Version: 4+
--- ---
Changelog: Deprecated passing constants as strings in PHP 4.2.0. Use the available constants instead. Passing constants as strings generates a warning message. <br> <br> Multiple locations can be passed in PHP 4.3.0. <br> <br> Since PHP 5.3.0, passing a string to the constant parameter that is not one of the LC_ constants throws an E_DEPRECATED notice.
--- ---

❮ Func Array Reset Php Intlchar ❯