Collator::__construct
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Collator::__construct — Create a collator
Description
$locale
)Creates a new instance of Collator.
Parameters
-
locale
-
The locale whose collation rules should be used. Special values for locales can be passed in - if null is passed for the locale, the default locale collation rules will be used. If empty string ("") or "root" are passed, UCA rules will be used.
The Locale attribute is typically the most important attribute for correct sorting and matching, according to the user expectations in different countries and regions. The default » UCA ordering will only sort a few languages such as Dutch and Portuguese correctly ("correctly" meaning according to the normal expectations for users of the languages). Otherwise, you need to supply the locale to UCA in order to properly collate text for a given language. Thus a locale needs to be supplied so as to choose a collator that is correctly tailored for that locale. The choice of a locale will automatically preset the values for all of the attributes to something that is reasonable for that locale. Thus most of the time the other attributes do not need to be explicitly set. In some cases, the choice of locale will make a difference in string comparison performance and/or sort key length.
Return Values
Returns Collator instance.
Errors/Exceptions
Returns an "empty" object on error. You can use intl_get_error_code() and/or intl_get_error_message() to know what happened.
Examples
Example #1 Collator::__construct() example
<?php
$coll = new Collator( 'en_CA' );
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Поддержка языков и кодировок
- Internationalization Functions
- Функция Collator::asort() - Sort array maintaining index association
- Функция Collator::compare() - Compare two Unicode strings
- Функция Collator::__construct() - Create a collator
- Функция Collator::create() - Create a collator
- Функция Collator::getAttribute() - Get collation attribute value
- Функция Collator::getErrorCode() - Get collator's last error code
- Функция Collator::getErrorMessage() - Get text for collator's last error code
- Функция Collator::getLocale() - Get the locale name of the collator
- Функция Collator::getSortKey() - Get sorting key for a string
- Функция Collator::getStrength() - Get current collation strength
- Функция Collator::setAttribute() - Set collation attribute
- Функция Collator::setStrength() - Set collation strength
- Функция Collator::sortWithSortKeys() - Sort array using specified collator and sort keys
- Функция Collator::sort() - Sort array using specified collator
Коментарии
404 Not Found