feof()` function in combination with a loop. feof()` function checks if the end-of-file has been reached, and returns `true` if it has, and `false` otherwise. feof()` function to read through a file line by line :<?php
$file = fopen("example.txt", "r") or die("Unable to open file!"); // open the file in read mode
while(!feof($file)) { // loop until end-of-file is reached
$line = fgets($file); // read a single line from the file
echo $line; // display the line
}
fclose($file); // close the file
?>example.txt" in read mode using the `fopen()` function. fgets()` function, stored it in the variable `$line`, and displayed it using the `echo` statement. Finally, we closed the file using the `fclose()` function.