Are there specific best practices for handling line breaks in text files when using PHP?

When handling line breaks in text files using PHP, it is important to consider the differences in line break characters between different operating systems (e.g., Windows uses "\r\n", Unix uses "\n", and Mac uses "\r"). To ensure consistent handling of line breaks, you can use the PHP function `PHP_EOL` which represents the correct line break character for the current platform.

// Read a file line by line and output its contents with consistent line breaks
$filename = 'example.txt';
$file = fopen($filename, 'r');

while (!feof($file)) {
    $line = fgets($file);
    echo $line . PHP_EOL;
}

fclose($file);