Home >>PHP String Functions >PHP setlocale() Function
PHP setlocale() function is used to set local information about the language, monetary, time, and other information for some particular geographical area. This function returns the new current locale and if the locale is not implemented then it returns false. The locale information can be set back to default by using setlocale(LC_ALL,NULL).
Syntax:
setlocale($constant,$location);
Parameter | Description |
---|---|
constant | This is a required parameter. This parameter defines what locale information should be set. Available constants:
|
location | This is a required parameter. This parameter defines what country/region to set the locale information. It can be a string or an array. |
Here is an example of setlocale() function in PHP:
<html> <body> <?php $location="US"; echo "Your Location is:".$location; echo "<br>"; echo "By using setlocale() function:".setlocale(LC_ALL,"$location"); ?> </body> </html>
Here is an another example of setlocale() function in PHP:
<html> <body> <?php echo setlocale(LC_ALL,"US"); echo "<br>"; echo setlocale(LC_ALL,NULL); ?> </body> </html>