PHP setlocale()関数
例
ロケールを米国英語に設定してから、再びデフォルトに戻します。
<?php
echo setlocale(LC_ALL,"US");
echo "<br>";
echo setlocale(LC_ALL,NULL);
?>
定義と使用法
setlocale()関数は、ロケール情報を設定します。
ロケール情報は、地理的領域に固有の言語、金銭、時間、およびその他の情報です。
注: setlocale()関数は、現在のスクリプトのロケールのみを変更します。
ヒント:ロケール情報は、setlocale(LC_ALL、NULL)を使用してシステムのデフォルトに設定できます。
ヒント:数値フォーマット情報を取得するには、 localeconv()関数を参照してください。
構文
setlocale(constant,location)
パラメータ値
Parameter | Description |
---|---|
constant | Required. Specifies what locale information should be set. Available constants:
|
location | Required. Specifies what country/region to set the locale information to. Can be a string or an array. It is possible to pass multiple locations. If the location is NULL or the empty string "", the location names will be set from the values of environment variables with the same names as the constants above, or from "LANG". If the location is "0", the location setting is not affected, only the current setting is returned. If the location is an array, setlocale() will try each array element until it finds a valid language or region code. This is very useful if a region is known under different names on different systems. Note: To view all available language codes, go to our Language code reference. |
技術的な詳細
戻り値: | 現在のロケール設定を返します。失敗した場合はFALSEを返します。戻り値は、PHPが実行されているシステムによって異なります。 |
---|---|
PHPバージョン: | 4歳以上 |
変更ログ: | PHP 5.3.0-LC_定数の代わりに文字列が定数パラメーターに渡された場合、この関数はE_DREPRECATED通知をスローします。 |
❮PHP文字列リファレンス