HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP tmpfile() Function


PHP Filesystem Reference Complete PHP Filesystem Reference

Definition and Usage

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

Syntax

tmpfile()


Tips and Notes

Note: The temporary file is automatically removed when it is closed with fclose(), or when the script ends.

Tip: See also tempnam()


Example

<?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 output of the code above will be:

Testing, testing.


PHP Filesystem Reference Complete PHP Filesystem Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE