Jump to: navigation, search

Php setlocale

From w3cyberlearnings

Contents

PHP function setlocale

This function sets locale information for time, langauge, monetary, and other specification for a geographical area.

Syntax setlocale

  • category: what locale information should be set
  • location: what country/region to set the locale information to.
setlocale(category, location)

Category:

  • LC_ALL for all of the below
  • LC_COLLATE for string comparison, see strcoll()
  • LC_CTYPE for character classification and conversion, for example strtoupper()
  • LC_MONETARY for localeconv()
  • LC_NUMERIC for decimal separator (See also localeconv())
  • LC_TIME for date and time formatting with strftime()
  • LC_MESSAGES for system responses (available if PHP was compiled with libintl)

Location:

  • " " or NULL force to set for the system's regional settings.
  • Complete reference of the Location setting ISO Codes: ISO 639 3 letter codes-obsolete *Note: This ISO 639 3 letter codes is not the most uptodate.

Example 1

<?php

echo setlocale(LC_ALL, 'nld_nld');
echo '<br/>';
echo setlocale(LC_ALL, NULL);
?>

Output

Dutch_Netherlands.1252
English_United States.1252

Example 2

<?php

echo setlocale(LC_ALL, 'khm');
echo '<br/>';
echo setlocale(LC_ALL, NULL);
?>
 

Output

Khmer_Cambodia.1252
English_United States.1252

Example 3

<?php

echo setlocale(LC_ALL, 'jpn');
echo '<br/>';
echo setlocale(LC_ALL, NULL);
?>

Output

Japanese_Japan.932
English_United States.1252

Related Functions


Navigation
Web
SQL
MISC
References