Alex Rivera | Logout

PHP newline not working in text file

Asked 2011-02-01T03:02:04.620
32

I am using the PHP code:

$numberNewline = $number . '\n';
fwrite($file, $numberNewline);

to write $number to a file.

For some reason \n appears in the file. I am on a mac. What might be the problem?

Edit
Report

1 Answer

73

'\n' in single quotes is a literal \n.
"\n" in double quotes is interpreted as a line break.

http://php.net/manual/en/language.types.string.php

answered 2011-02-01T03:04:21.417

Your Answer