PHP feof () ฟังก์ชัน
ความหมายและการใช้งาน
จะ feof () ฟังก์ชั่นการตรวจสอบได้ถึงจุดสิ้นสุดของไฟล์ (EOF)
หากเกิดความผิดพลาดหรือแฟ้มชี้ไปยังจุดสิ้นสุดของไฟล์ (EOF) ส่งกลับ TRUE มิฉะนั้นก็จะส่งกลับ FALSE
ไวยากรณ์
feof(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的打开文件。 |
เคล็ดลับและคำอธิบาย
เคล็ดลับ: feof () ฟังก์ชั่นในการสำรวจความยาวของข้อมูลที่ไม่รู้จักที่จะเป็นประโยชน์
ตัวอย่าง
<?php
$file = fopen("test.txt", "r");
//Output a line of the file until the end is reached
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
$file = fopen("test.txt", "r");
//Output a line of the file until the end is reached
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
รหัสข้างต้นส่งออกจะ:
Hello, this is a test file.
There are three lines here.
This is the last line.
There are three lines here.
This is the last line.
เสร็จสมบูรณ์คู่มือการใช้งานระบบแฟ้ม PHP อ้างอิง