How can one efficiently read a file line by line in PHP?
Reading a file line by line in PHP can be efficiently done using the `fgets()` function within a while loop. This allows you to read each line of the file sequentially without loading the entire file into memory at once.
$filename = "example.txt";
$handle = fopen($filename, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
echo $line;
}
fclose($handle);
} else {
echo "Error opening the file.";
}