8
我正面临着PHP文件I/O的问题。追加后PHP文件大小不变
$file = fopen("/tmp/test.txt", "w");
fwrite($file,"hi there\n");
fclose($file);
echo filesize("/tmp/test.txt")."\n"; # displays 9
$file = fopen("/tmp/test.txt", "a");
fwrite($file,"hi there\n");
fclose($file);
echo filesize("/tmp/test.txt")."\n"; # also displays 9 !!!!!!!
可以看到,我在初始写入后通过追加来改变文件大小。为什么我在这两种情况下获得9个文件大小?我期待18输出的情况下,2
该脚本执行后的文件内容是什么? – hsz
亲爱的hsz它有预期的内容。它有18个字符。 – user1033837