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
  • Test whether the file pointer reaches the end of the file feof

    feof

    Testwhetherthefilepo
  • Output file readfile

    readfile

    Outputfile
  • Synchronize changes to files (including metadata) fsync

    fsync

    Synchronizechangesto
  • Get file size filesize

    filesize

    Getfilesize
  • Read a line from a file pointer and filter out HTML tags fgetss

    fgetss

    Readalinefromafilepo
  • Return the target of the symbolic link readlink

    readlink

    Returnthetargetofthe
  • Positioning in file pointer fseek

    fseek

    Positioninginfilepoi
  • Change the group to which the file belongs chgrp

    chgrp

    Changethegrouptowhic
Popular Articles