What are the differences between \n, \r, and \r\n when trying to create line breaks in PHP file writing operations?
When writing to a file in PHP, different operating systems use different characters to represent line breaks. \n represents a line feed (LF) character, \r represents a carriage return (CR) character, and \r\n represents a carriage return followed by a line feed (CRLF) character. To ensure cross-platform compatibility, it's best to use \r\n when creating line breaks in PHP file writing operations.
<?php
$file = fopen("example.txt", "w");
fwrite($file, "Hello\r\nWorld\r\n");
fclose($file);
?>