Avatar ·

When should I use the PHP_EOL constant in PHP and how is it different from \\n?

Hello everyone! I'm a beginner PHP developer and I'm confused about the PHP_EOL constant. The documentation says it's "the correct newline character for the current platform," but I don't fully understand when to use it. Here's an example: I'm writing a script that saves logs to a text file. Currently I'm using regular : ```php $log = date('Y-m-d H:i:s') . " - User logged in"; file_put_contents('log.txt', $log, FILE_APPEND); ``` On my local server (Windows) everything works fine. But when I uploaded the code to production (Linux), I noticed that in some places lines are merged together, and in others they aren't. A friend advised me to replace with PHP_EOL, but I don't understand: why, if works everywhere? I also write HTML emails with multi-line messages. There I also use