What are the different line endings used for Windows, Linux, and Mac systems in PHP?

Different operating systems use different characters for line endings - Windows uses "\r\n", Linux uses "\n", and Mac uses "\r". This can cause issues when working with files that have been created on different systems. To ensure cross-platform compatibility, you can use the PHP constant PHP_EOL, which represents the correct line ending for the current operating system.

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