可能重複:
How do i purge the contents of a text file in php擦除從txt文件的所有數據 - PHP
嗨..
我怎樣才能刪除存儲的所有數據(請空白)在我文本文件myfile.txt
使用php ??
可能重複:
How do i purge the contents of a text file in php擦除從txt文件的所有數據 - PHP
嗨..
我怎樣才能刪除存儲的所有數據(請空白)在我文本文件myfile.txt
使用php ??
$handle = fopen ("/path/to/file.txt", "w+");
fclose($handle);
請查看documentation瞭解更多信息。
在這種情況下,PHP的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);
你有你的參數向後... – 2011-04-13 14:37:26
@克里斯 - 修正了@Robik – Treffynnon 2011-04-13 14:39:14
@Treggynnon感謝。 @克里斯感謝信息 – Robik 2011-04-13 14:39:33