PHP Linefeeds (\n) Not Working

Posted by dosboy on Stack Overflow See other posts from Stack Overflow or by dosboy
Published on 2010-06-10T15:48:58Z Indexed on 2010/06/10 15:52 UTC
Read the original article Hit count: 289

Filed under:
|

For some reason I can't use \n to create a linefeed when outputting to a file with PHP. It just writes "\n" to the file. I've tried using "\\n" as well, where it just writes "\n" (as expected). But I can't for the life of me figure out why adding \n to my strings isn't creating new lines. I've also tried \r\n but it just appends "\r\n" to the line in the file.

Example:

error_log('test\n', 3, 'error.log');
error_log('test2\n', 3, 'error.log');

Outputs:

test\ntest2\n

Using MAMP on OSX in case that matters (some sort of PHP config thing maybe?).

Any suggestions?

© Stack Overflow or respective owner

Related posts about php

Related posts about newline