English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP feof() Function Usage and Example

PHP Filesystem Reference Manual

The feof() function checks if the "end of file" (EOF) has been reached. If an error occurs or the EOF is reached, this function can return true, otherwise it can return false.

Syntax

bool feof ( resource $handle )

 Test if the file pointer has reached the end of the file. The feof() function can be used to traverse data of unknown length.

Online Example

<?php
   $file = fopen("/PhpProject/sample.txt, "r");
   
   //Output a line from the file until the end
   while(! feof($file)) {
      echo fgets($file);
   }
   fclose($file);
?>

Output Result

oldtoolbag.com
www.oldtoolbag.com

PHP Filesystem Reference Manual