大网数据广告活动
PHP 语言与运行手册

Internationalization Functions

· 52CE 我爱测

Internationalization extension (further is referred as Intl) is a wrapper for » ICU library, enabling PHP programmers to perform various locale-aware operations including but not limited to formatting, transliteration, encoding conversion, calendar operations, » UCA-conformant co

Internationalization Functions

简介

Internationalization extension (further is referred as Intl) is a wrapper for » ICU library, enabling PHP programmers to perform various locale-aware operations including but not limited to formatting, transliteration, encoding conversion, calendar operations, » UCA-conformant collation, locating text boundaries and working with locale identifiers, timezones and graphemes.

It tends to closely follow ICU APIs, so that people having experience working with ICU in either C/C++ or Java could easily use the PHP API. Also, this way ICU documentation would be useful to understand various ICU functions.

Intl consists of several modules, each of them exposes the corresponding ICU API:

  • Collator: provides string comparison capability with support for appropriate locale-sensitive sort orderings.

  • Number Formatter: allows to display number according to the localized format or given pattern or set of rules, and to parse strings into numbers.

  • Message Formatter: allows to create messages incorporating data (such as numbers or dates) formatted according to given pattern and locale rules, and parse messages extracting data from them. It can handle plurals, locale-aware numbers, currencies, conditions and much more.

  • Normalizer: provides a function to transform text into one of the Unicode normalization forms, and provides a routine to test if a given string is already normalized.

  • Locale: provides interaction with locale identifiers in the form of functions to get subtags from locale identifier; parse, compose, match (lookup and filter) locale identifiers.

  • Calendar: provides a class which could be used for locale-aware calendar operations and getting various information such as timezone for locale chosen, first day of week or if it's daylight saving time now.

  • Timezone: provides a wrapper around the » "Olson" database which has information about all the timezones around the world.

  • Date formatter: allows to display date and time according to the localized format or given pattern or set of rules, and to parse strings into date and time.

  • Transliterator: allows getting latin representation of strings in various languages.

注意:

As of PHP 8.4.0, cloning an Intl object consistently throws an Error when the clone cannot be performed, either because the object has not been initialized (created without invoking its constructor), or because the underlying ICU clone operation failed. Formerly, most of these classes threw an Exception instead, and Spoofchecker raised a fatal error.

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。