PHP md5_file() Function (original) (raw)

Last Updated : 11 Jul, 2025

The md5_file() function is an inbuilt function in PHP which is used to generate the md5 hash value of a given file. This function returns a string on success otherwise it returns FALSE.Syntax:

md5_file( file,file, file,raw )

Parameters: This function accepts two parameters as mentioned above and described below.

Return Value: This function returns a string of MD5 hash on success and returns FALSE otherwise. Supposed there is a file named "gfg.txt" which has below content:

Publish your own articles and share knowledge with the world!!

Below programs illustrate the md5_file() function:Program 1:

php `

`

Output:

1d4e50ae1992ad8adf2f7bb6ee4dd0cd

Program 2: With optional parameter $raw with different values TRUE and FALSE.

php `

`

Output:

1d4e50ae1992ad8adf2f7bb6ee4dd0cd
1d4e50ae1992ad8adf2f7bb6ee4dd0cd ????/{??M??

Reference: https://www.php.net/manual/en/function.md5-file.php