Php/docs/numberformatter.getlocale

提供:Dev Guides
< Php
移動先:案内検索

NumberFormatter::getLocale

numfmt_get_locale

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

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


説明

オブジェクト指向型

public NumberFormatter::getLocale ([ int $type ] ) : string

手続き型

numfmt_get_locale ( NumberFormatter $fmt [, int $type ] ) : string

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


パラメータ

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


返り値

フォーマッタの作成時に使用したロケールを返します。


例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

参考