I am facing a problem with PHP file 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 !!!!!!!
As one can see, I am changing the file size after the initial write by appending to it. Why do I get 9 as file size in both the cases? I'm expecting 18 as the output in case 2.