< Complete PHP Filesystem Reference
Definition and Usage
The tmpfile() function creates a temporary file with a unique name in read-write (w+) mode.
Syntax
tmpfile()
Tips and Notes
Note: The temporary file is automatically removed when it is closed with fclose() , or when the script ends.
Tip: See also tempnam()
Example
<?php
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//Rewind to the start of file
rewind($temp);
//Read 1k from file
echo fread($temp,1024);
//This removes the file
fclose($temp);
?>
The output of the code above will be:
Testing, testing.
< Complete PHP Filesystem Reference