PHP feof() Function

Definition

feof() takes a file handle and returns true if you are at the end of the file or false otherwise.

Syntax

PHP feof() Function has the following syntax.

feof(file)

Parameter

ParameterIs RequiredDescription
fileRequired.Open file to check

Return

This function returns TRUE if an error occurs, or if EOF has been reached. Otherwise it returns FALSE.

Example

The feof() function checks if the "end-of-file" (EOF) has been reached.


<?PHP/*  w  w  w.  ja  v  a 2s .c o  m*/
$huge_file = fopen("VERY_BIG_FILE.txt", "r");
while (!feof($huge_file)) {
   print fread($huge_file, 1024);
}
fclose($huge_file);

?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions