Home > Article > Backend Development > php feof function_PHP tutorial
Returns TRUE if the file pointer reaches EOF or an error occurs, otherwise returns an error (including socket timeout), otherwise returns FALSE.
Definition and usage
The feof() function detects whether the end of file (eof) has been reached.
Returns true if the file pointer reaches eof or an error occurs, otherwise returns an error (including socket timeout), otherwise returns false.
Grammar
feof(file) parameter description
file required. Specifies the open file to be checked.
Description
The file parameter is a file pointer. This file pointer must be valid and must point to a file that was successfully opened by fopen() or fsockopen() (but has not been closed by fclose()).
$fh = fopen("/home/www.bkjia.com/data/users.txt", "rt");
while (!feof($fh)) echo fgets($fh);
fclose($fh);
?>