Possible duplicate:How to clear text file contents in php
Hi..
How to erase all saved data (empty) in the text file myfile.txt using php ??
myfile.txt
$handle = fopen ("/path/to/file.txt", "w+"); fclose($handle);
See additional documentation.
PHP file_put_contents() should be useful in this case. Here is a sample code:
file_put_contents()
file_put_contents('myfile.txt', '');
<?php file_put_contents("myfile.txt", ""); ?>
$file = fopen('myfile.txt', 'w'); fclose($file);
$handle = fopen("myfile.txt", "w+"); fwrite($handle , ''); fclose($handle);
$myFile = "myFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, ""); fclose($fh);
Source: https://habr.com/ru/post/885828/More articles:Delete vs directory file + update performance - c #Windows Service Installation Project - visual-studio-2010FTP transfers all files in the remote directory and sets permissions using PHP - phpCompiler switch to disable const_cast semantics in c-style casts? - c ++Create an instance of a class when declaring a variable or inside a constructor - actionscriptChoosing when to instantiate classes - javaSolr and MySQL, How do I keep an updated index, and is DB required if it's simple? - databaseRecovery error output - javaIs chmod 757 safe? - security37signals Highrise.NET (C #) API - c #All Articles