略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Basic usage of this extension

2024-12-22

Basic usage of this extension

Each module provides two kind of APIs: a procedural one and an object oriented one. Both are actually identical and described in the corresponding document.

注意:

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

示例 #1 Example of using the procedural API

<?php
$coll  
collator_create('en_US');
$result collator_compare($coll"string#1""string#2");
?>

示例 #2 Example of using the object-oriented API

<?php
$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);
?>
add a noteadd a note

User Contributed Notes 1 note

up
3
RoboTamer
10 years ago
Get the default currency for a country:

<?php
$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);
?>

官方地址:https://www.php.net/manual/en/intl.examples.basic.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3