晕,这样就行了<?PHP
function wf($c, $f, $m = "w+"){
$fp = @fopen($f, $m);
@fwrite($fp, $c);
@fclose($fp);
return true;
}for($i = 0; $i < 100; $i ++){
$c = file_get_contents("c:\\t.txt");
$c .= "\r\n".$i;
wf($c, "c:\\t.txt");
}
?>
function wf($c, $f, $m = "w+"){
$fp = @fopen($f, $m);
@fwrite($fp, $c);
@fclose($fp);
return true;
}for($i = 0; $i < 100; $i ++){
$c = file_get_contents("c:\\t.txt");
$c .= "\r\n".$i;
wf($c, "c:\\t.txt");
}
?>
你这样写一个数字就要打开和关闭一次文件太没效率了
应该打开,然后写,等写完了再关闭
<?php
$fp = fopen("C:\\t.txt", 'w');
for($i = 0; $i < 100; $i++) {
fwrite($fp, $i);
}
fclose($fp);
?>