PHP/File Directory/fclose

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

Close a file you have opened with fopen( ), use fclose( ).

   <source lang="html4strict">

<?

   $filename = "data.txt";
   $handle = fopen($filename, "rb");
   $contents = fread($handle, filesize($filename));
   fclose($handle);
   print $contents;

?>

 </source>
   
  


fclose() function closes the file

   <source lang="html4strict">

int fclose (int filepointer) <?

   $file = "data.txt";
   if (file_exists($file)) :
        $fh = fopen($file, "r");
        fclose($fh);
   else:
        print "File $file does not exist!";
   endif;

?>

 </source>