The tmpfile() function creates a temporary file with a unique file name in read-write (w+) mode.
tmpfile()
Note: Temporary files are automatically deleted after the file is closed (using fclose()) or when the script ends.
Tip: See tempnam().
<?php$temp = tmpfile();fwrite($temp, "Testing, testing.");//Rewind to the start of filerewind($temp);//Read 1k from fileecho fread($temp,1024); //This removes the filefclose($temp);?>
The above code will output:
Testing, testing.