What is the difference between using "\n" and "\r\n" for creating new lines in a file in PHP?

Using "\n" creates a new line in a file that is compatible with Unix-based systems, while "\r\n" creates a new line that is compatible with Windows-based systems. If you are working on a cross-platform project, it is recommended to use "\r\n" to ensure compatibility across different systems. However, if you are specifically targeting Unix-based systems, "\n" should suffice.

// Using "\r\n" to create a new line in a file
$file = fopen("example.txt", "w");
fwrite($file, "Line 1\r\nLine 2\r\nLine 3");
fclose($file);