且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用PHP编写新行文件

更新时间:2023-12-04 13:44:52

'\\\
'
替换为 \\\
。当您使用'时,转义序列无法识别。

Replace '\n' with "\n". The escape sequence is not recognized when you use '.

请参阅手动

有关如何写行尾的问题,请参阅请注意此处。基本上,不同的操作系统对于线路结束有不同的约定。 Windows使用\\\\,基于unix的操作系统使用\\\
。你应该坚持一个惯例(我选择了\\\
),并以二进制模式打开你的文件( fopen 应该得到wb而不是w) 。

For the question of how to write line endings, see the note here. Basically, different operating systems have different conventions for line endings. Windows uses "\r\n", unix based operating systems use "\n". You should stick to one convention (I'd chose "\n") and open your file in binary mode (fopen should get "wb", not "w").