array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'class.locale.php', 1 => 'Locale', ), 'up' => array ( 0 => 'book.intl.php', 1 => 'intl', ), 'prev' => array ( 0 => 'numberformatter.settextattribute.php', 1 => 'NumberFormatter::setTextAttribute', ), 'next' => array ( 0 => 'locale.acceptfromhttp.php', 1 => 'Locale::acceptFromHttp', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/intl/locale.xml', ), 'extra_header_links' => array ( 'rel' => 'alternate', 'href' => '/manual/en/feeds/class.locale.atom', 'type' => 'application/atom+xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use. Locales are identified using RFC 4646 language tags (which use hyphen, not underscore) in addition to the more traditional underscore-using identifiers. Unless otherwise noted the functions in this class are tolerant of both formats.
Examples of identifiers include:
The Locale class (and related procedural functions) are used to interact with locale identifiers--to verify that an ID is well-formed, valid, etc. The extensions used by CLDR in UAX #35 (and inherited by ICU) are valid and used wherever they would be in ICU normally.
Locales cannot be instantiated as objects. All of the functions/methods provided are static.
The null or empty string obtains the "root" locale. The "root" locale is equivalent to "en_US_POSIX" in CLDR. Language tags (and thus locale identifiers) are case insensitive. There exists a canonicalization function to make case match the specification.
Locale::DEFAULT_LOCALE
These constants describe the choice of the locale for the getLocale method of different classes.
Locale::ACTUAL_LOCALE
Locale::VALID_LOCALE
These constants define how the Locales are parsed or composed. They should be used as keys in the argument array to locale_compose() and are returned from locale_parse() as keys of the returned associative array.
Locale::LANG_TAG
Locale::EXTLANG_TAG
Locale::SCRIPT_TAG
Locale::REGION_TAG
Locale::VARIANT_TAG
Locale::GRANDFATHERED_LANG_TAG
Locale::PRIVATE_TAG