feof() Function Checks whether the end of file (EOF) has been reached.
If an error occurs or the file pointer reaches the end of the file (EOF), TRUE is returned, otherwise FALSE is returned. The feof() function is useful for iterating over data of unknown length.
Syntax
feof(file)
Description | |
---|---|
Required. Specifies the open file to be checked. |
<?php $file = fopen("test.txt", "r"); //输出文本中所有的行,直到文件结束为止。 while(! feof($file)) { echo fgets($file). "<br />"; } fclose($file); ?>
The above is the detailed content of Usage of php feof() function. For more information, please follow other related articles on the PHP Chinese website!