PHP/File Directory/fclose

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

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

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



fclose() function closes the file

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