Creates a temporary file with a unique name in read-write (w+) mode in PHP

Description

The following code shows how to creates a temporary file with a unique name in read-write (w+) mode.

Example


  /*  ww  w . j ava 2 s . c om*/
<?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 code above generates the following result.





















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip