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