fgets() function returns a string read from a file. : fgets « File Directory « PHP






fgets() function returns a string read from a file.

 
Its syntax is: string fgets (int filepointer, int length)

<?
$fh = fopen("data.txt", "r");
while (! feof($fh)) :
     $line = fgets($fh, 4096);
     print $line."<br>";
endwhile;
fclose($fh);
?>
  
  








Related examples in the same category

1.Checking for an error from fopen(), fgets(), or fclose()
2.Counting paragraphs in a file
3.Counting records in a file
4.Creating and Using a File Class
5.Reading a compressed file
6.Reading a file a line at a time
7.fgets.php
8.Processing a list of books
9.Processing each word in a file