php8.5
Home/ Manual/ filesystem / functions/ fclose

fclose

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Closes an open file pointer

Description

fclose(resource $stream): bool

The file pointed to by stream is closed.

Parameters

stream

The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().

Return Values

Success

Examples

A simple fclose() example

php
<?php

$handle = fopen('somefile.txt', 'r');

fclose($handle);

?>

See Also

Source: reference/filesystem/functions/fclose.xml · from the official PHP manual (php/doc-en)