Home>Article>Backend Development> How to delete txt file content in php
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.
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!