PHP feof() ဖော်ပြသည်

အသုံးချက် နှင့် အပြုအမူ

feof() ဖော်ပြသည် ဖိုင် အဆုံး ရောက်ခဲ့လာပုံကို စစ်ဆေးသည် (eof)。

Returns TRUE if the file pointer reaches EOF or an error occurs, otherwise returns an error (including socket timeout), otherwise returns FALSE.

Syntax

feof(file)
Parameter Description
file Required. Specifies the open file to be checked.

Description

file The parameter is a file pointer. This file pointer must be valid and must point to a file opened by fopen() Or fsockopen() successfully opened (but not yet) fclose() Closing) the file.

Tips and comments

Tip:feof() function is very useful for traversing data of unknown length.

Note:If the server does not close the connection opened by fsockopen(), feof() will keep waiting until the timeout and return TRUE. The default timeout limit is 60 seconds, and you can change this value using stream_set_timeout().

Note:If the passed file pointer is invalid, it may fall into an infinite loop because EOF does not return TRUE.

Example

<?php
$file = fopen("test.txt", "r");
//Output all lines 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.