PHP tmpfile()Funciones


PHP Filesystem 参考手册Manual de referencia completo de PHP Filesystem

Definición y uso

La función tmpfile() crea un archivo temporal con un nombre de archivo único en modo lectura/escritura (w+).

Sintaxis

tmpfile()


Consejos y notas

Nota:El archivo temporal se eliminará automáticamente después de que se cierre el archivo (con fclose()) o cuando termine el script.

Consejo:Ver también tempnam().


Ejemplos

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

El código anterior generará:

Testing, testing.


PHP Filesystem 参考手册Manual de referencia completo de PHP Filesystem Otras extensiones