PHP finfo_close() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The finfo_close() function is an inbuilt function in PHP that is used to close the file instance that is opened by the finfo_open() function. Syntax: finfo_close($finfo): boolParameters: This function accepts only one parameter which is described below. $finfo: The file info resource returned by finfo_open() function.Return Values: The finfo_close() function returns true if this function successfully closes the finfo instance of the file otherwise this function will return "false". Program 1: The following program demonstrates the finfo_close() function. Make sure the "text.txt" file is available in the given root location. PHP <?php $finfoinstance = finfo_open(FILEINFO_MIME, null); if (!$finfoinstance) { echo "Opening file data is failed"; exit(); } // Return file MIME $filename = "./text.txt"; echo finfo_file($finfoinstance, $filename); finfo_close($finfoinstance); ?> Output: application/x-empty; charset=binaryProgram 2: The following program demonstrates the finfo_close() function. Make sure the given "output.txt" file is available in the given location. PHP <?php // Create a new Fileinfo resource $fileInfo = finfo_open(FILEINFO_MIME_TYPE); // Check if the Fileinfo resource // was created successfully if (!$fileInfo) { die("Failed to create Fileinfo resource."); } // Get the file type of a specific file $filename = "./output.txt"; $fileType = finfo_file($fileInfo, $filename); echo "File type of $filename is: $fileType\n"; // Close the Fileinfo resource finfo_close($fileInfo); ?> Output: File type of ./output.txt is: text/plainReference: https://www.php.net/manual/en/function.finfo-close.php Comment More infoAdvertise with us Next Article PHP finfo_close() Function neeraj3304 Follow Improve Article Tags : PHP Similar Reads PHP finfo_file() Function The finfo_file() function is an inbuilt function in PHP that is used for getting information about a file. Syntax: Procedural Style: public finfo_file( string $filename, int $flags = FILEINFO_NONE, ?resource $context = null ): string|false Object-Oriented Style: public finfo::file( string $filename, 2 min read PHP fclose() Function The fclose() function in PHP closes a file that was previously opened by fopen(). Closing a file releases the resource associated with it and makes sure all the data written to the file is properly saved. Not closing files can lead to resource leaks or incomplete data writing.Syntax:bool fclose(reso 2 min read PHP | closedir( ) Function The closedir() function in PHP is an inbuilt function which is used to close a directory handle. The directory handle to be closed is sent as a parameter to the closedir() function and the closedir() closes the directory handle. The directory handle must be previously opened by the opendir() functio 2 min read PHP finfo_buffer() Function The finfo_buffer() is an inbuilt function in PHP that returns information about a string buffer. Syntax: Procedural Style: string | false finfo_uffer( string $string, int $flags = FILEINFO_NONE, ?resource $context = null )Object-Oriented Style: public finfo::buffer( string $string, int $flags = FILE 1 min read PHP | zip_close( ) Function The zip_close() function is an inbuilt function in PHP which is used to close a zip archive file opened by the zip_open() function. The zip_close() causes the stream to be closed and the connection to the corresponding Zip Archive to be broken. The zip resource which has been opened by the zip_open( 2 min read PHP finfo_open() Function The finfo_open() function is an inbuilt function in PHP that creates a new info instance. This function is in PHP 7 and 8. Syntax: Procedural Style:finfo_open(Flag, magic_database = null)Object-Oriented Style:public finfo::__construct(Flag, $magic_database = null)Parameters: This function has only t 1 min read PHP | zip_entry_close() Function The zip_entry_close() function is an inbuilt function in PHP which is used to close a zip archive opened by the zip_entry_open() function. The zip_entry_close() causes the stream to be closed and the connection to the corresponding Zip Archive Entry which may be a file or a directory within the Zip 3 min read PHP | ftp_connect() function The ftp_connect() function is an inbuilt function in PHP which is used to create a new connection to the specified FTP server or Host. When connection is successful then only other FTP functions can be run against the server. Syntax:Â ftp_connect( $ftp_host, $ftp_port, $timeout ); Parameter: This fu 2 min read PHP end() Function The end() function is an inbuilt function in PHP and is used to find the last element of the given array. The end() function changes the internal pointer of an array to point to the last element and returns the value of the last element.Syntax:end($array)Parameters:This function accepts a single par 2 min read PHP fscanf() Function The fscanf() function is an inbuilt function in PHP that parses the file's input according to format, i.e., it accepts the input from a file that is associated with the stream & the input will be interpreted according to the specified format. This function is similar to sscanf() function. Any wh 2 min read Like