1. Computing & Technology

Discuss in my forum

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.
Related Searches feof echo data myfile yourfile lt br

©2012 About.com. All rights reserved.

A part of The New York Times Company.