1. Computing

Discuss in my forum

Fgets () PHP Function

By , About.com Guide

Definition: The PHP function fgets () is used to read a file line by line. This will only work if the file data is stored on separate new lines, if it is not this will not produce the results you are looking for. It is phrased as: fgets (handle, length). The File must be opened in the handle. Length does not need to be included, but it will default to 1024 bytes if it is not specified.
Examples:
 <?php 
 $myFile = "YourFile.txt"; 
 $handle = fopen($myFile, 'r'); 
 while (!feof($handle)) 
 { 
 $data = fgets($handle, 512); 
 echo $data; 
 echo "<br>"; 
 } 
 fclose($handle); 
 ?> 
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. PHP Functions
  5. Fgets - Fgets PHP - Fgets Tutorial

©2013 About.com. All rights reserved.