A brief analysis of the problem that \r\n cannot be used to wrap lines when writing txt files using php fwrite

高洛峰
Release: 2023-03-05 10:56:01
Original
1812 people have browsed it

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我已经换行了!");
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template