Home > Backend Development > PHP Problem > How to delete txt file content in php

How to delete txt file content in php

藏色散人
Release: 2023-03-04 22:24:01
Original
4942 people have browsed it

How to delete the contents of a txt file in php: first use the fopen function to open the file; then use the fclose method to close the file or directly write an empty string.

How to delete txt file content in php

Recommended: "PHP Video Tutorial"

php delete txt file content:

1. You can open the file and then close it, for example:

$fclose($fopen('abc.txt','w'));
Copy after login

2. You can also write an empty string directly, for example:

file_put_contents('abc.txt','');
Copy after login

The above is the detailed content of How to delete txt file content in php. For more information, please follow other related articles on 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