从txt文件中删除所有数据 - PHP

6
6个回答

10

在此情况下,PHP的file_put_contents()应该是有用的。以下是一些示例代码:

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

1
你的参数顺序颠倒了... - Chris Eberle

7
$handle = fopen ("/path/to/file.txt", "w+");
fclose($handle);

查看文档以获取更多信息。


4
<?php
file_put_contents("myfile.txt", "");
?>

1
$file = fopen('myfile.txt', 'w');
fclose($file);

0
$handle = fopen("myfile.txt", "w+");
fwrite($handle , '');
fclose($handle);

0
$myFile = "myFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "");
fclose($fh);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接