• PHP Video Tutorials

PHP - Function feof()



The feof() function checks if "end-of-file" (EOF) has reached. This function can return true if an error occurs or EOF has reached, otherwise it can return false.

Syntax

bool feof ( resource $handle )

The feof() function can be useful for traversing data of unknown length.

Example

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

Output

tutorialspoint
tutorix
php_function_reference.htm
Advertisements