Home  >  Article  >  Backend Development  >  Usage of php feof() function

Usage of php feof() function

怪我咯
怪我咯Original
2017-07-10 17:00:102353browse

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)



##ParametersDescriptionfileRequired. Specifies the open file to be checked.
Example code


<?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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn