PHP 7 tmpfile() Function❮ PHP Filesystem Reference
Create a temporary file with a unique name in read-write (w+) mode:
$temp = tmpfile();
fwrite($temp, "Testing, testing.");
//Rewind to the start of file
//Read 1k from file
//This removes the file
The output of the code above will be:
Definition and Usage
The tmpfile() function creates a temporary file with a unique name in read-write (w+) mode.
Note: The file is automatically removed when closed, with fclose() or when the script ends.
Tip: See also the tempnam() function.
|Return Value:||A file handle (similar to the one returned by fopen() for the new file), FALSE on failure|
❮ PHP Filesystem Reference