Line break not working when writing to text file in PHP

六月ゝ 毕业季﹏ 提交于 2019-11-27 13:07:40

If you want to open the file in Windows notepad, you must use Windows line breaks: \r\n

It is best to use PHP_EOL. This is cross-platform, so it automatically chooses the correct newline character(s) for the platform PHP is currently running on.

$stringData = "Floppy Jalopy" . PHP_EOL;

PHP Constants

Your code runs fine.

Use Notepad2 or Notepad++ if you're working on Windows. The built-in Notepad is unable to cope with Unix-style line endings.

. PHP_EOL; will work universally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!