PHP feof() Function
In this chapter you will learn:
- Definition for PHP feof() Function
- Syntax for PHP feof() Function
- Parameter for PHP feof() Function
- Return for PHP feof() Function
- Example - checks if the "end-of-file" (EOF) has been reached
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//from j av 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);
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP fflush() Function
- Syntax for PHP fflush() Function
- Parameter for PHP fflush() Function
- Return for PHP fflush() Function
- Example - Writes all buffered output to an open file
Home » PHP Tutorial » PHP File Functions