• 首页
  • css3教程
  • html5教程
  • vue手册
  • php手册
  • MySQL手册
  • redis手册
  • jQuery手册
  • 位置: php 中文手册

    php 国际化功能



    Intl 配置选项
    intl.use_exceptions0PHP_INI_ALLAvailable since PHP 5.5 and PECL 3.0.0a1



    The locale that will be used in intl functions when none is specified (either by omitting the corresponding argument or by passingNULL). These are ICU locales, not system locales. The built-in ICU locales and their data can be explored at » http://demo.icu-project.org/icu-bin/locexp.

    The default value is empty, which forces the usage of ICU's default locale. Once set, the ini setting cannot be reset to this default value. It is not recommended that this default be relied on, as its effective value depends on the server's environment.


    The level of the error messages generated when an error occurs in ICU functions. This is a PHP error level, such as E_WARNING. It can be set to0in order to inhibit the messages. This does not affect the return values indicating error or the values returned by intl_get_error_code() or by the class specific methods for retrieving error codes and messages. ChoosingE_ERRORwill terminate the script whenever an error condition is found on intl classes.

    The default value is0.


    If set to true, an exception will be raised whenever an error occurs in an intl function. The exception will be of type IntlException. This is possibly in addition to the error message generated due to intl.error_level.

    The default value is FALSE.




    All input strings must be in UTF-8 encoding. All output strings are also in UTF-8.

    Example #1 Example of using the procedural API

    $coll  = collator_create('en_US');
    $result = collator_compare($coll, "string#1", "string#2");

    Example #2 Example of using the object-oriented API

    $coll = new Collator('en_US');
    $al   = $coll->getLocale(Locale::ACTUAL_LOCALE);
    echo "Actual locale: $al\n";
    $formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
    echo $formatter->format(1234567);
    Get the default currency for a country:
    $formatter = new NumberFormatter('de_DE', NumberFormatter::CURRENCY);
    echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_CODE);
    $formatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
    echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_CODE);
    $formatter = new NumberFormatter('ja_JP', NumberFormatter::CURRENCY);
    echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_CODE);