How can the differences in line endings between operating systems affect the display of text files generated by PHP?

The differences in line endings between operating systems can affect the display of text files generated by PHP because some operating systems use different characters to represent line breaks (e.g., Windows uses \r\n, Unix uses \n). This can result in text files appearing incorrectly formatted when viewed on different systems. To solve this issue, PHP developers can use the PHP_EOL constant, which represents the correct line ending for the current platform, when writing to text files.

$file = fopen("output.txt", "w");
fwrite($file, "Hello" . PHP_EOL . "World");
fclose($file);