Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP feof() Function

PHP feof() Function


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual


Definition and Usage

The feof() function checks whether the end of file (EOF) has been reached.

Returns TRUE on error or when the file pointer reaches the end of file (EOF), otherwise returns FALSE.

Syntax

feof(file)

Parameters Description
file Required. Specifies the open file to check.

Tips and Notes

**Tip:** The feof() function is useful for looping through data of unknown length.


Example

The following example outputs every line of a file until the last line is reached:

Example

" ; } fclose ( $file ) ; ?>

The code above will output:

Hello, this is a test file.
There are three lines here.
This is the last line.

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual