I encountered a problem today that when using fwrite to write a txt file, I cannot use rn to wrap the line.
I tried for a long time but couldn’t find a solution!
Suddenly I thought of something that I had seen in a book before and then I still used this. Dongdong has solved it!
Write it now to prevent forgetting in the future and hope it can help friends who need help!
Look at the code directly:
<?php $stream = fopen("robots.txt", "w+"); fwrite($stream, "你换行了吗\r\n我已经换行了!"); ?>
More analysis of how php fwrite writes txt files When using \r\n, you cannot wrap the line. For related articles, please pay attention to the PHP Chinese website!