Are there any best practices for reading and displaying multiple lines from a file in PHP?

When reading and displaying multiple lines from a file in PHP, it is best practice to use a loop to read each line one by one and display them accordingly. This ensures that the file is read line by line and prevents memory issues with large files. Additionally, using functions like `fgets()` or `file()` can simplify the process of reading lines from a file.

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

if ($file) {
    while (($line = fgets($file)) !== false) {
        echo $line . "<br>";
    }
    fclose($file);
} else {
    echo "Error opening file.";
}