Gli ultimi tutorial di sviluppo web
 

PHP tmpfile() Function


<Completa PHP Filesystem di riferimento

Definizione e l'utilizzo

Il tmpfile() funzione crea un file temporaneo con un nome univoco in lettura-scrittura (w+) modalità.

Sintassi

tmpfile()

Suggerimenti e Note

Note: Il file temporaneo viene rimosso automaticamente quando viene chiuso con fclose() , oppure quando lo script finisce.

Tip: Vedere anche tempnam()


Esempio

<?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);
?>

L'output del codice precedente sarà:

Testing, testing.

<Completa PHP Filesystem di riferimento