What are some best practices for handling line-by-line parsing of text files in PHP?

When parsing text files line-by-line in PHP, it is best practice to use the `fgets()` function within a `while` loop to read each line until the end of the file is reached. This approach ensures efficient memory usage and allows for processing large text files without loading the entire file into memory at once.

$filename = 'example.txt';
$file = fopen($filename, 'r');

if ($file) {
    while (($line = fgets($file)) !== false) {
        // Process each line here
        echo $line;
    }

    fclose($file);
} else {
    echo "Error opening file.";
}