How does the interpretation of line breaks differ between operating systems in PHP?
Line breaks in PHP can differ between operating systems due to the way each system handles line endings. Windows uses "\r\n" (carriage return followed by line feed) for line breaks, while Unix-based systems like Linux and macOS use just "\n" for line breaks. To ensure consistent line breaks across different operating systems, you can use the PHP_EOL constant, which represents the correct line ending for the current platform.
// Use PHP_EOL constant to ensure consistent line breaks
$text = "This is a line of text" . PHP_EOL;
file_put_contents('output.txt', $text, FILE_APPEND);