PHP feof () function reads the file

xiaoxiao2021-03-06  40

(PHP 4, PHP 5)

FeOF - Test the file pointer to the end of the file

If the server does not turn off the connection opened by fsockopen (), Feof () will wait until the timeout 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 point to files that have been successfully opened by fopen () or fsockink () (and not yet fed from fclose ()).

If the passed file pointer is invalid, it may fall into an infinite loop because EOF will not return true.

EXAMPLE # 1 example of FeOF () using invalid file pointers

example

$ file = fopen ($ _ server ['Document_Root']. "/ me / test.txt", "r");

// Output all rows in the text until the file ends.

While (! Feof ($ file))

{

Echo fgets ($ file). "

}

Fclose ($ file);

?>

Output:

Hello, this is a test file.

There is three.

This is the last line.

转载请注明原文地址:https://www.9cbs.com/read-72846.html

New Post(0)