PHP/File Directory/Temporary file

Материал из Web эксперт
Перейти к: навигация, поиск

Creating a temporary file in a particular place

   <source lang="html4strict">

<?php $dir = dirname($existing_file); $temp = tempnam($dir,"temp"); $temp_fh = fopen($temp,"w"); ?>

 </source>
   
  


Creating a temporary file with tempnam()

   <source lang="html4strict">

<?php $tempfilename = tempnam("/tmp","data-"); $temp_fh = fopen($tempfilename,"w") or die($php_errormsg); fputs($temp_fh,"The current time is ".strftime("%c")); fclose($temp_fh) or die($php_errormsg); ?>

 </source>
   
  


Creating a temporary file with tmpfile()

   <source lang="html4strict">

<?php $temp_fh = tmpfile(); fputs($temp_fh,"The current time is ".strftime("%c")); exit(1); ?>

 </source>