CakeFest 2024: The Official CakePHP Conference

NumberFormatter::getLocale

numfmt_get_locale

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

NumberFormatter::getLocale -- numfmt_get_localeフォーマッタのロケールを取得する

説明

オブジェクト指向型

public NumberFormatter::getLocale(int $type = ULOC_ACTUAL_LOCALE): string|false

手続き型

numfmt_get_locale(NumberFormatter $formatter, int $type = ULOC_ACTUAL_LOCALE): string|false

フォーマッタのロケール名を取得します。

パラメータ

formatter

NumberFormatter オブジェクト。

type

妥当なロケールあるいは正確なロケールのいずれか ( Locale::VALID_LOCALE, Locale::ACTUAL_LOCALE, respectively) を選択します。デフォルトは実際のロケールです。

戻り値

フォーマッタの作成時に使用したロケールを返します。 失敗した場合は false を返します。

例1 numfmt_get_locale() の例

<?php
$req
= 'fr_FR_PARIS';
$fmt = numfmt_create( $req, NumberFormatter::DECIMAL);
$res_val = numfmt_get_locale( $fmt, Locale::VALID_LOCALE );
$res_act = numfmt_get_locale( $fmt, Locale::ACTUAL_LOCALE );
printf( "Requested locale name: %s\nValid locale name: %s\nActual locale name: %s\n",
$req, $res_val, $res_act );
?>

上の例の出力は以下となります。

Requested locale name: fr_FR_PARIS
Valid locale name: fr_FR
Actual locale name: fr

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top