CakeFest 2024: The Official CakePHP Conference

基本的な使用法

各モジュールには、 手続き型とオブジェクト指向型の二種類の API が存在します。 それぞれの API について、対応するドキュメントで説明します。

注意:

入力文字列は、すべて UTF-8 でエンコードされていなければなりません。 出力文字列も、すべて UTF-8 となります。

例1 手続き型 API の使用例

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

例2 オブジェクト指向型 API の使用例

<?php
$coll
= new Collator('en_US');
$al = $coll->getLocale(Locale::ACTUAL_LOCALE);
echo
"実際のロケール: $al\n";

$formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
echo
$formatter->format(1234567);
?>
add a note

User Contributed Notes 1 note

up
4
RoboTamer
11 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);
?>
To Top