Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | zip_close( ) Function
Next article icon

PHP finfo_close() Function

Last Updated : 24 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): bool

Parameters: 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=binary

Program 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/plain

Reference: https://www.php.net/manual/en/function.finfo-close.php


Next Article
PHP | zip_close( ) Function
author
neeraj3304
Improve
Article Tags :
  • Web Technologies
  • 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 is an inbuilt function that is used to close a file that is pointed by an open file pointer. The fclose() function returns true on success and false on failure. It takes the file as an argument that has to be closed and closes that file. Syntax: bool fclose( $file )Param
    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 pa
    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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences