The fclose() function closes an open file.
PHP fclose() Function has the following syntax.
fclose(file)
Parameter | Is Required | Description |
---|---|---|
file | Required. | Specifies the file to close |
PHP fclose() Function returns TRUE on success or FALSE on failure.
To close a file you have opened with fopen(), use fclose().
<?PHP
$filename = "c:/abc/test.txt";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
print $contents;
?>
In that example, fopen() is called with rb as the second parameter, for "read-only, binary-safe".