PHP setlocale() Function
Complete PHP String Reference
Definition and Usage
The setlocale() function sets locale information.
Locale information is language, monetary, time and other information specific
for a geographical area.
This function returns the current locale settings, or FALSE on failure.
Syntax
setlocale(constant,location)
|
Parameter |
Description |
constant |
Required. Specifies what locale information should be set.
Available constants:
- LC_ALL - All of the below
- LC_COLLATE - Sort order
- LC_CTYPE - Character classification and conversion (e.g. all
characters should be lower or upper-case)
- LC_MESSAGES - System message formatting
- LC_MONETARY - Monetary/currency formatting
- LC_NUMERIC - Numeric formatting
- LC_TIME - Date and time formatting
|
location |
Required. Specifies what country/region to set the locale
information to. Can be a string or an array. If the location is an array, setlocale() will try each array element until it finds a valid language or
region code. This is very useful if a region is known under different names
on different systems. Note: Here you can find
language and
region codes. |
Tips and Notes
Note: The setlocale() function changes the locale only for the current
script.
Tip: The
locale information can be set to system default with setlocale(LC_ALL,NULL)
Example
In this example we will set the locale to US English and then back to default
again:
<?php
echo setlocale(LC_ALL,"En-Us");
echo "<br />";
echo setlocale(LC_ALL,NULL);
?>
|
The output of the code above will be:
English_United States.1252
Norwegian (Bokmål)_Norway.1252
|
Complete PHP String Reference
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|