I wrote some pretty complex PHP applications using this function, so I'm not sure what is going on here.
I am currently writing an application that uses online history to save content (via ajax get). The API I wrote to store user history in a file is very simple:
$myFile = "./snhistory/".$_GET["uid"];
$stringData = urldecode($_GET["name"])."\n";
$file = fopen($myFile,"a");
fwrite($file,$stringData);
fclose($file);
It looks like code that adds the data found in name, plus a new line to the end of the file, right? Well, thatβs not how PHP sees it. It adds one name, then when I run the code with a different name, it overwrites the first and only the second appears. I tried everything I could think:
file_put_contents($myFile,file_get_contents($myFile).$stringData);
and
file_put_contents($myFile,$stringData,FILE_APPEND);
AND
fopen($myFile,"w");
fseek($file,0,SEEK_END);
. - PHP, - ? , , , , . , .
, .
: , , ', - URL . .