PHP fclose() function

Definition and Usage

The fclose() function closes an open file.

Syntax

fclose(file)
Parameter Description
file Required. Specifies the file to be closed.

Description

file The parameter is a file pointer. The fclose() function closes the file pointed to by the pointer.

Returns true if successful, otherwise returns false.

The file pointer must be valid and obtained through fopen() or fsockopen() Successfully opened.

Example

<?php
$file = fopen("test.txt","r");
//Some code executed...
fclose($file);
?>