Home > Backend Development > PHP Tutorial > PHP如何写入文件开头

PHP如何写入文件开头

WBOY
Release: 2016-06-06 20:44:35
Original
1215 people have browsed it

w w+ 会把文件清空再写

r r+ 会定位在文件尾部

如果想写入文件的开头,只能把文件读入字符串拼接之后在存入文件么?

回复内容:

w w+ 会把文件清空再写

r r+ 会定位在文件尾部

如果想写入文件的开头,只能把文件读入字符串拼接之后在存入文件么?

是的。

另外在尾部追加应该用 a。

fread 出 全部字符串,然后拼接到前面。 file_put_contents 字符串到文件中。

Related labels:
php
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