Funkcja setlocale() PHP
Przykład
Ustaw ustawienia regionalne na angielski amerykański, a następnie z powrotem na domyślne:
<?php
echo setlocale(LC_ALL,"US");
echo "<br>";
echo setlocale(LC_ALL,NULL);
?>
Definicja i użycie
Funkcja setlocale() ustawia informacje o lokalizacji.
Informacje regionalne to język, pieniądze, czas i inne informacje specyficzne dla obszaru geograficznego.
Uwaga: Funkcja setlocale() zmienia ustawienia narodowe tylko dla bieżącego skryptu.
Wskazówka: informacje o ustawieniach regionalnych można ustawić na domyślne systemowe za pomocą setlocale(LC_ALL,NULL)
Wskazówka: Aby uzyskać informacje o formatowaniu liczb, zobacz funkcję localeconv() .
Składnia
setlocale(constant,location)
Wartości parametrów
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. |
Szczegóły techniczne
Wartość zwrotu: | Zwraca bieżące ustawienia regionalne lub FALSE w przypadku niepowodzenia. Zwracana wartość zależy od systemu, w którym działa PHP. |
---|---|
Wersja PHP: | 4+ |
Dziennik zmian: | PHP 5.3.0 - Jeśli łańcuch jest przekazywany do parametru stałej zamiast jednej ze stałych LC_, ta funkcja wyświetla ostrzeżenie E_DREPRECATED. |
❮ Odniesienie do ciągów PHP