Λειτουργία setlocale() του PHP
Δείγμα
Ρύθμιση της περιοχής ως US English και επαναφορά ως προεπιλεγμένη του συστήματος:
<?php echo setlocale(LC_ALL, "US"); echo "<br>"; echo setlocale(LC_ALL, NULL); ?>
Ορισμός και Χρήση
Η λειτουργία setlocale() ρυθμίζει τις πληροφορίες περιοχής (γεωγραφικές πληροφορίες).
Οι πληροφορίες περιοχής αφορούν τη γλώσσα, την κούρσα, την ώρα και άλλες πληροφορίες μιας γεωγραφικής περιοχής.
Comments:Η λειτουργία setlocale() αλλάζει τις πληροφορίες περιοχής μόνο για το τρέχον σενάριο.
Συμβουλή:Οι πληροφορίες περιοχής μπορούν να ρυθμιστούν ως προεπιλεγμένες του συστήματος με setlocale(LC_ALL, NULL).
Συμβουλή:Για πληροφορίες μορφοποίησης αριθμών, παρακαλώ δείτε localeconv() Λειτουργία.
Γραμματική
setlocale(constant,location)
Παράμετροι | Περιγραφή |
---|---|
constant |
Απαιτείται. Ορίζει τι πληροφορίες περιοχής πρέπει να γίνει ρύθμιση. Διαθέσιμοι Σταθεροί:
|
location |
Required. Specifies which country/region to set the locale information to. It can be a string or an array. Multiple locations can be passed. If location If the parameter is NULL or an empty string "", the location name will be set to the value of the environment variable with the same name as the above constants or set according to "LANG". If location The parameter is "0", the location setting is not affected, and only the current setting is returned. If location The parameter is an array, and setlocale() will try each array element until a valid language or locale code is found. This is very useful if a location has different names on different systems. Comments:To view all available language codes, please visit ourLanguage Code Reference Manual. |
Technical Details
Return Value: | Returns the current locale settings, or FALSE if fails. The return value depends on the system running PHP. |
PHP Version: | 4+ |
Update Log: |
In PHP 4.2.0, the deprecated practice of passing constants as strings has been deprecated. Please use the available constants instead. Passing constants as strings will produce a warning message. In PHP 4.3.0, multiple locations can be passed. Since PHP 5.3.0, if passed to constant The parameter is a string, not one of the LC_ constants, and the function will throw an E_DREPRECATED notification. |