1$handle = fopen("inputfile.txt", "r");
2if ($handle) {
3 while (($line = fgets($handle)) !== false) {
4 // process the line read.
5 }
6
7 fclose($handle);
8} else {
9 // error opening the file.
10}
1<?php
2
3 $file = new SplFileObject("file.txt");
4
5 while(!$file->eof())
6 {
7 echo $file->fgets()."<br/>";
8 }
9
10 $file = null;
11
12?>