【发布时间】:2011-11-07 13:39:34
【问题描述】:
我遇到了 PHP 文件 I/O 的问题。
$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 它有预期的内容。它有 18 个字符。
标签: php caching file-io filesize