ไฟล์ PHP ()ฟังก์ชั่น
❮ การอ้างอิงระบบไฟล์ PHPตัวอย่าง
อ่านไฟล์ลงในอาร์เรย์:
<?php
print_r(file("test.txt"));
?>
ความหมายและการใช้งาน
file() อ่านไฟล์ในอาร์เรย์
องค์ประกอบอาร์เรย์แต่ละรายการมีบรรทัดจากไฟล์ โดยที่อักขระขึ้นบรรทัดใหม่ยังคงแนบอยู่
ไวยากรณ์
file(filename, flag, context)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
filename | Required. Specifies the path to the file to read |
flag |
Optional. Can be one or more of the following constants:
|
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL. |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ไฟล์ทั้งหมดในอาร์เรย์ FALSE เมื่อล้มเหลว |
---|---|
รุ่น PHP: | 4.0+ |
ตู้เซฟไบนารี: | ใช่ ใน PHP 4.3 |
❮ การอ้างอิงระบบไฟล์ PHP