Home  >  Article  >  Backend Development  >  php writes file without overwriting

php writes file without overwriting

王林
王林Original
2019-09-17 13:06:013166browse

php writes file without overwriting

file_put_contents(): Write content to the file without overwriting the previous content.

Steps:

1. Create a new file

php writes file without overwriting

2. Declare the file to be written into.

php writes file without overwriting

3. The content of this file is as shown in the figure

php writes file without overwriting

4. file_get_contents reads the content of the file

php writes file without overwriting

5. In the file content Then directly write the content to be written and assign it to the variable

php writes file without overwriting

6. File_put_contents writes the content

php writes file without overwriting

7. Refresh the page and the file content will change

php writes file without overwriting

The above content is for reference only!

Recommended tutorial: PHP video tutorial

The above is the detailed content of php writes file without overwriting. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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