How can different operating systems affect the interpretation of line breaks in text files created using PHP?

Different operating systems have different conventions for representing line breaks in text files. For example, Windows uses a carriage return followed by a line feed (\r\n), while Unix-based systems use just a line feed (\n). This can lead to issues when reading text files created on one operating system on another. To ensure cross-platform compatibility, you can use the PHP_EOL constant, which represents the correct line break sequence for the current operating system.

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