Zezombia Posted July 24, 2010 Share Posted July 24, 2010 I'm posting this from an AJAX script: <?php $file = fopen('log.txt', 'a'); fwrite($file, '\r\n' . $_GET['name'] . ': ' . $_GET['text']); fclose($file); ?> Unfortunately it literary writes \r\n instead of creating a new line. What's the proper method of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/208746-simple-question-new-line-in-text-file/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 24, 2010 Share Posted July 24, 2010 You need to use double-quotes around the \r\n Ref: http://www.php.net/manual/en/language.types.string.php Quote Link to comment https://forums.phpfreaks.com/topic/208746-simple-question-new-line-in-text-file/#findComment-1090536 Share on other sites More sharing options...
wildteen88 Posted July 24, 2010 Share Posted July 24, 2010 You need to use double-quotes around the \r\n Another method is to use the PHP constant PHP_EOL Quote Link to comment https://forums.phpfreaks.com/topic/208746-simple-question-new-line-in-text-file/#findComment-1090621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.