(PHP 4, PHP 5)
Feof-test whether the file pointer is at the end of the file
If the server does not close the connection opened by fsockopen (), feof () waits until it times out and returns TRUE. The default timeout limit is 60 seconds. You can use stream_set_timeout () to change this value.
The file pointer must be valid and must be directed to a file successfully opened by fopen () or fsockopen () (not closed by fclose ).
If the passed file pointer is invalid, it may be in an infinite loop, because EOF does not return TRUE.
Example #1 Example of using feof () with invalid file pointer
<? Php
// If the file cannot be read or does not exist, the fopen function returns FALSE.
$ File = @ fopen ("no_such_file", "r ");
// FALSE from fopen generates a warning message and falls into an infinite loop here
While (! Feof ($ file )){
}
Fclose ($ file );
?>
Example
<? Php
$ File = fopen ($ _ SERVER ['document _ root']. "/me/test.txt", "r ");
// Output all rows in the text until the end of the file.
While (! Feof ($ file ))
{
Echo fgets ($ file). "<br/> ";
}
Fclose ($ file );
?>
Output:
Hello, this is a test file.
There are three lines here.
This is the last line.