What is the purpose of using "\r\n" in PHP when writing to a text file?
Using "\r\n" in PHP when writing to a text file is important for ensuring cross-platform compatibility in the formatting of the text. "\r\n" represents a line break in Windows, while "\n" is used for Unix-based systems. By using "\r\n", you can ensure that the text file will display correctly on both Windows and Unix systems.
<?php
$file = fopen("example.txt", "w");
fwrite($file, "Hello\r\nWorld!");
fclose($file);
?>