Computer >> Computer tutorials >  >> Programming >> PHP

tmpfile()function in PHP


The tmpfile() function creates a unique temporary file. It returns file pointer for the new file or FALSE on failure.

Syntax

tmpfile()

Parameters

  • NA

Return

The tmpfile() function returns file pointer for the new file or FALSE on failure.

Example

<?php
   $tmpfile = tmpfile();
   fwrite($tmpfile, "This is demo text in temp file!");
   rewind($tmpfile);
   echo fread($tmpfile, 1024);
   fclose($tmpfile);
?>

Output

This is demo text in temp file!