$tmpfname = tempnam(”/tmp”, “FOO”);
$handle = fopen($tmpfname, “w”);
fwrite($handle, “writing to tempfile”);
fclose($handle);
// do here something
unlink($tmpfname);
when using unlink() in windows, after using fopen() must use fclose() so that the file can be deleted