PHP feof () function
Definition and Usage
Are feof () function checks have reached the end of the file (EOF).
If an error occurs, or the file pointer to the end of the file (EOF) returns TRUE, otherwise it returns FALSE.
grammar
feof(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的打开文件。 |
Tips and Notes
Tip: feof () function to traverse the length of the unknown data is useful.
Examples
<?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);
?>
The code above will output:
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.
Complete PHP Filesystem Reference Manual