PHP finfo_file() Function Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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, int $flags = FILEINFO_NONE, ?resource $context = null ): string|false Parameters: This function accept four parameters that are described below: finfo: It specifies an instance for finfo, which returns by finfo_open().filename: It specifies the name of the file that we want to check.flags: This is file info constants.context: By default, this null is assigned for a description of contexts.Return Value: This function returns the textual description of the content of file, or false if an error occurred Example 1: In the below example, we will print the file information using the finfo_file() function. 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 Example 2: In the below example, we will print the file information using finfo_file() functions. PHP <?php $finfo = finfo_open(FILEINFO_MIME_TYPE); foreach (glob("*") as $filename) { echo finfo_file($finfo,$filename) . "\n"; } finfo_close($finfo); ?> Output: text/x-php application/x-empty Reference: https://www.php.net/manual/en/function.finfo-file.php Comment More infoAdvertise with us Next Article PHP | fileatime( ) Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function PHP-Fileinfo Similar Reads PHP finfo_close() Function 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 fin 2 min read PHP fileinode() Function The fileinode() function is an inbuilt function in PHP that returns the inode of the file. Syntax: fileinode(string $filename): int|falseParameter: This function has only one parameter: filename: This parameter specifies the path for the particular file.Return Value: This function returns the inode 1 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 | filesize( ) Function The filesize() function in PHP is an inbuilt function which is used to return the size of a specified file. The filesize() function accepts the filename as a parameter and returns the size of a file in bytes on success and False on failure. The result of the filesize() function is cached and a funct 2 min read PHP | fileatime( ) Function The fileatime() function in PHP is an inbuilt function which is used to return the last access time of a specified file. The fileatime() function returns the last access time of a file as a Unix Timestamp on success and False on failure. The filename is passed as a parameter to the fileatime() funct 2 min read PHP | filemtime( ) Function The filemtime() function in PHP is an inbuilt function which is used to return the last time of a specified file when its content was modified. The filemtime() function returns the last time the file was changed as a Unix Timestamp on success and False on failure. The filename is passed as a paramet 2 min read Like