What are the differences in handling line breaks (\n) and carriage returns (\r) in PHP scripts, especially when dealing with different operating systems like Unix and Windows?

When dealing with line breaks (\n) and carriage returns (\r) in PHP scripts, it's important to consider the differences between Unix and Windows operating systems. Unix systems use only \n for line breaks, while Windows systems use \r\n. To ensure cross-platform compatibility, you can use the PHP_EOL constant which represents the correct end-of-line character for the current platform.

// Use PHP_EOL to handle line breaks in a cross-platform compatible way
$text = "Hello" . PHP_EOL . "World";
echo $text;