PHP readfile()ฟังก์ชั่น
❮ การอ้างอิงระบบไฟล์ PHPตัวอย่าง
อ่านไฟล์:
<?php
echo readfile("test.txt");
?>
ความหมายและการใช้งาน
ฟังก์ชัน readfile() อ่านไฟล์และเขียนลงในบัฟเฟอร์เอาต์พุต
เคล็ดลับ:คุณสามารถใช้ URL เป็นชื่อไฟล์ที่มีฟังก์ชันนี้ได้ หากไฟล์ fopen wrappers ถูกเปิดใช้งานในไฟล์ php.ini
ไวยากรณ์
readfile(file, include_path, context)
ค่าพารามิเตอร์
Parameter | Description |
---|---|
file | Required. Specifies the file to read |
include_path | Optional. Set this parameter to TRUE if you want to search for the file in the include_path (in php.ini) as well |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream |
รายละเอียดทางเทคนิค
คืนมูลค่า: | จำนวนไบต์ที่อ่านสำเร็จ FALSE และข้อผิดพลาดเมื่อล้มเหลว คุณสามารถซ่อนข้อความแสดงข้อผิดพลาดได้โดยเพิ่ม '@' หน้าชื่อฟังก์ชัน |
---|---|
รุ่น PHP: | 4.0+ |
บันทึกการเปลี่ยนแปลง PHP: | PHP 5.0: เพิ่มการสนับสนุนบริบท |
❮ การอ้างอิงระบบไฟล์ PHP