feof() function in PHP

The feof() function tests for end-of-file on a file pointer. It returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.

Syntax

feof(file_pointer)

Parameters

  • file_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose())

Return

The feof() function returns TRUE if the file pointer is at EOF or an error occurs, otherwise returns FALSE.

Example

<?php
   $file_pointer = @fopen("/files/f.php", "r");
   if ($file_pointer) {
      while (!feof($file_pointer)) {
         $buffer = fgetss($file_pointer, 1024);
         echo $buffer;
      }
      fclose($file_pointer);
   }
?>

Output

First line

kabeer

Added  Sep 11, 11:00 pm

Article tags

Php
×
Google login
SignUp with Email
X