PHP setlocale() Fungsi
Contoh
Setel lokal ke Bahasa Inggris AS dan kemudian kembali ke default lagi:
<?php
echo setlocale(LC_ALL,"US");
echo "<br>";
echo setlocale(LC_ALL,NULL);
?>
Definisi dan Penggunaan
Fungsi setlocale() mengatur informasi lokal.
Informasi lokal adalah bahasa, moneter, waktu, dan informasi lain yang spesifik untuk wilayah geografis.
Catatan: Fungsi setlocale() mengubah lokal hanya untuk skrip saat ini.
Tip: Informasi lokal dapat diatur ke default sistem dengan setlocale(LC_ALL,NULL)
Tips: Untuk mendapatkan informasi pemformatan numerik, lihat fungsi localeconv() .
Sintaksis
setlocale(constant,location)
Nilai Parameter
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. |
Detail Teknis
Nilai Kembali: | Mengembalikan pengaturan lokal saat ini, atau FALSE pada kegagalan. Nilai pengembalian tergantung pada sistem yang dijalankan PHP. |
---|---|
Versi PHP: | 4+ |
Catatan perubahan: | PHP 5.3.0 - Jika sebuah string dilewatkan ke parameter konstan alih-alih salah satu konstanta LC_, fungsi ini menampilkan pemberitahuan E_DREPRECATE. |
Referensi String PHP