Función PHP tmpfile()
❮ Referencia del sistema de archivos PHPEjemplo
Cree un archivo temporal con un nombre único en modo lectura-escritura (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);
?>
La salida del código anterior será:
Testing, testing.
Definición y uso
La función tmpfile() crea un archivo temporal con un nombre único en modo lectura-escritura (w+).
Nota: El archivo se elimina automáticamente cuando se cierra, con fclose() o cuando finaliza el script.
Sugerencia: consulte también la función tempnam() .
Sintaxis
tmpfile()
Detalles técnicos
Valor devuelto: | Un identificador de archivo (similar al devuelto por fopen() para el nuevo archivo), FALSO en caso de falla |
---|---|
Versión PHP: | 4.0+ |
❮ Referencia del sistema de archivos PHP