PHP tmpfile() Funzione
❮ Riferimento al file system PHPEsempio
Crea un file temporaneo con un nome univoco in modalità lettura-scrittura (w+):
<?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 sopra sarà:
Testing, testing.
Definizione e utilizzo
La funzione tmpfile() crea un file temporaneo con un nome univoco in modalità lettura-scrittura (w+).
Nota: il file viene automaticamente rimosso alla chiusura, con fclose() o al termine dello script.
Suggerimento: vedere anche la funzione tempnam() .
Sintassi
tmpfile()
Dettagli tecnici
Valore di ritorno: | Un handle di file (simile a quello restituito da fopen() per il nuovo file), FALSE in caso di errore |
---|---|
Versione PHP: | 4.0+ |
❮ Riferimento al file system PHP