PHP setlocale() Funktion
Beispiel
Stellen Sie das Gebietsschema auf US-Englisch und dann wieder auf die Standardeinstellungen zurück:
<?php
echo setlocale(LC_ALL,"US");
echo "<br>";
echo setlocale(LC_ALL,NULL);
?>
Definition und Verwendung
Die Funktion setlocale() setzt Gebietsschemainformationen.
Gebietsschemainformationen sind Sprach-, Geld-, Zeit- und andere Informationen, die für ein geografisches Gebiet spezifisch sind.
Hinweis: Die Funktion setlocale() ändert das Gebietsschema nur für das aktuelle Skript.
Tipp: Die Locale-Informationen können mit setlocale(LC_ALL,NULL) auf den Systemstandard gesetzt werden.
Tipp: Informationen zur numerischen Formatierung finden Sie unter der Funktion localeconv() .
Syntax
setlocale(constant,location)
Parameterwerte
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. |
Technische Details
Rückgabewert: | Gibt die aktuellen Gebietsschemaeinstellungen oder FALSE bei einem Fehler zurück. Der Rückgabewert hängt von dem System ab, auf dem PHP läuft. |
---|---|
PHP-Version: | 4+ |
Änderungsprotokoll: | PHP 5.3.0 - Wenn anstelle einer der LC_-Konstanten ein String an den konstanten Parameter übergeben wird, wirft diese Funktion eine E_DREPRECATED-Benachrichtigung. |
❮ PHP-String-Referenz