(PHP 4, PHP 5)
feof-Test If the file pointer is at the end of the file
If the server does not close the connection opened by Fsockopen (), feof () waits until the timeout expires and returns true. The default time-out limit is 60 seconds, and you can use Stream_set_timeout () to change the value.
The file pointer must be valid and must point to a file that was successfully opened by fopen () or Fsockopen () (and not yet closed by fclose ()).
If the passed file pointer is invalid, it may fall into an infinite loop because EOF does not return TRUE.
Example #1 the feof () example using invalid file pointers
If the file is unreadable or does not exist, the fopen function returns FALSE
$file = @fopen ("No_such_file", "R");
FALSE from fopen sends a warning message and is trapped here in an infinite loop.
while (!feof ($file)) {
}
Fclose ($file);
?>
Example
$file = fopen ($_server[' document_root '). " /me/test.txt "," R ");
Prints all the lines in the text until the end of the file.
while (! feof ($file))
{
Echo fgets ($file). "
";
}
Fclose ($file);
?>
Output:
Hello, this is a test file.
There is three lines here.
The last line.
http://www.bkjia.com/PHPjc/756104.html www.bkjia.com true http://www.bkjia.com/PHPjc/756104.html techarticle (PHP 4, PHP 5) feof Test If the file pointer is to the end of the file if the server does not close the connection opened by Fsockopen (), feof () waits until it expires and returns T ...