Home > Backend Development > PHP Tutorial > Usage of php feof() function

Usage of php feof() function

怪我咯
Release: 2023-03-13 13:06:02
Original
2402 people have browsed it

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)
Copy after login



##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);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template