1. Home
  2. Computing & Technology
  3. PHP / MySQL

Feof PHP Function

By , About.com Guide

Definition: The feof () PHP Function is used to test for the end of a file. It is often used in a loop, to keep a process going until everything in the document has been processed. It is phrased as: feof($file) but more often seen as !feof($file).
Examples:
<?php
$myFile = "YourFile.txt";
$handle = fopen($myFile, 'r');
while (!feof($handle))
{
$data = fgets($handle, 512);
echo $data;
echo "<br>";
}
fclose($handle);
?>
This returns the data from the file as long as feof () is not true. When it is true (you have reached the end of the file) then the loop is exited.
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. PHP Feof - PHP end of file - Feof php function

©2009 About.com, a part of The New York Times Company.

All rights reserved.