Current Location: Home> Function Categories> tmpfile

tmpfile

Create a temporary file
Name:tmpfile
Category:File system
Programming Language:php
One-line Description:Create temporary files.

Definition and usage

tmpfile() function creates a temporary file with a unique file name in read-write (w+) mode.

The file will be automatically deleted after it is closed (using fclose() ), or when the script is finished.

Example

 <?php
$temp = tmpfile ( ) ;

fwrite ( $temp , "Testing, testing." ) ;

//Rewind back to the beginning of the file
rewind ( $temp ) ;

//Read 1k from the file
echo fread ( $temp , 1024 ) ;

//Delete the file
fclose ( $temp ) ;
?>

Output:

 Testing, testing.

grammar

 tmpfile ( )
Similar Functions
Popular Articles