在此情况下,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);