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

How to delete txt file content in php

藏色散人
藏色散人 Original
2020-08-22 09:02:04 4817browse

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'));

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

file_put_contents('abc.txt','');

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!

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