PHP Conference Japan 2024

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_LOCALELocale::ACTUAL_LOCALE)。 預設值為實際的地區設定。

回傳值

用於建立格式器的地區設定名稱,失敗時則回傳 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( "要求的地區設定名稱:%s\n有效的地區設定名稱:%s\n實際的地區設定名稱:%s\n",
$req, $res_val, $res_act );
?>

以上範例的輸出

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

參見

新增註記

使用者貢獻的註記

此頁面沒有使用者貢獻的註記。
To Top