In PHP on the server side (not from a webpage), you can do this if the file doesn't exist or you want to replace the contents:
Code:
$myFile = "/var/www/html/somewhere/somefile.dat";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $variable);
fclose($fh);
and if the file exists and you want to append to it, you could then:
Code:
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, $string1);
fwrite($fh, $string2);
You would first test to see if the file exists, then branch to the code part you need.....
Reading it back usefully is not quite as simple.
Bookmarks