tmpfile
PHP Manual
PHP Manual»Filesystem Funzioni»tmpfile

tmpfile

(PHP 4, PHP 5, PHP 7, PHP 8)

tmpfileCrea un file temporaneo

Descrizione

function tmpfile(): resource

Crea un file temporaneo con un nome univoco in modalità di lettura-scrittura (w+), restituendo un riferimento al file simile a quello tornato da fopen(). Il file viene automaticamente cancellato una volta chiuso (usando fclose()), o quando lo script termina.

Per dettagli, consulta la documentazione del tuo sistema sulla funzione tmpfile(3), così come il file haeader stdio.h.

Example #1 tmpfile() example

<?php 
         $temp = tmpfile(); 
         fwrite($temp, "writing to tempfile"); 
         fseek($temp, 0);
         echo fread($temp, 1024);
         fclose($temp);  // this removes the file 
         ?>

Il precedente esempio visualizzerà:

         writing toi tempfile
         

Vedere anche tempnam().

To Top