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

Live Demo

<?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!

Updated on: 30-Jul-2019

34 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements