PHP parse_ini_string()ฟังก์ชั่น
❮ การอ้างอิงระบบไฟล์ PHPตัวอย่าง
แยกสตริง ini:
$ini = '
[names]
me = "Robert"
you = "Peter"
[urls]
first = "http://www.example.com"
second = "https://www.w3schools.com"
';
print_r(parse_ini_string($ini));
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
Array
(
[names] => Array
(
[me] => Robert
[you] => Peter
)
[urls] => Array
(
[first] => http://www.example.com
[second] => https://www.w3schools.com
)
)
ความหมายและการใช้งาน
ฟังก์ชัน parse_ini_file() แยกวิเคราะห์สตริงการกำหนดค่า (ini) และคืนค่าการตั้งค่า
เคล็ดลับ:ฟังก์ชันนี้สามารถใช้เพื่ออ่านในไฟล์กำหนดค่าของคุณเอง และไม่มีส่วนเกี่ยวข้องกับไฟล์ php.ini
หมายเหตุ:ต้องไม่ใช้คำสงวนต่อไปนี้เป็นคีย์สำหรับไฟล์ ini: null, yes, no, true, false, on, off, none นอกจากนี้ ต้องไม่ใช้อักขระสงวนต่อไปนี้ในคีย์: {}|&~!()^"
ไวยากรณ์
parse_ini_string(ini, process_sections, scanner_mode)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
ini | Required. Specifies the ini file to parse |
process_sections | Optional. If set to TRUE, it returns is a multidimensional array with section names and settings included. Default is FALSE |
scanner_mode |
Optional. Can be one of the following values:
|
รายละเอียดทางเทคนิค
คืนมูลค่า: | อาร์เรย์ที่ประสบความสำเร็จ FALSE เมื่อล้มเหลว |
---|---|
รุ่น PHP: | 5.3+ |
❮ การอ้างอิงระบบไฟล์ PHP