PHP feof() Function
Definition
feof() takes a file handle and returns true if you are at the end of the file or false otherwise.
Syntax
PHP feof() Function has the following syntax.
feof(file)
Parameter
Parameter | Is Required | Description |
---|---|---|
file | Required. | Open file to check |
Return
This function returns TRUE if an error occurs, or if EOF has been reached. Otherwise it returns FALSE.
Example
The feof() function checks if the "end-of-file" (EOF) has been reached.
<?PHP/* w w w. ja v a 2s .c o m*/
$huge_file = fopen("VERY_BIG_FILE.txt", "r");
while (!feof($huge_file)) {
print fread($huge_file, 1024);
}
fclose($huge_file);
?>