PHP finfo_file() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes 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 finfo_file() Function 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 PHP | filectime( ) Function The filectime() function in PHP is an inbuilt function which is used to return the last time the specified file was changed. The filectime() function returns the last time the file was changed as a Unix Timestamp on success and False on failure. The filectime() function checks for inode changes whic 2 min read PHP fileowner() Function The fileowner() is an inbuilt function in PHP that returns the details for the file owner. Syntax: fileowner(string $filename): int|falseParameters: This function accepts a single parameter: filename: This parameter specifies the file path for the specific file.Name of the file. Return Value: The us 1 min read PHP is_file( ) Function The is_file() function in PHP is an inbuilt function which is used to check whether the specified file is a regular file or not. The name of the file is sent as a parameter to the is_file() function and it returns True if the file is a regular file else it returns False. Syntax: bool is_file($file) 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 Like