Menu Home

md5_file

osbo.com | PHP | Functions | md5_file

Calculates the md5 hash of a given file

Syntax

md5_file ( string $filename [, bool $raw_output = FALSE ] ) : string

Parameters

filename

The filename

raw_output

When TRUE, returns the digest in raw binary format with a length of 16.

Return

Returns a string on success, FALSE otherwise.

Examples

filename

<?

$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/file.txt';

$return = md5_file($filename);

echo $return;

?>
8b1a9953c4611296a827abf8c47804d7

raw_output

<?

$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/file.txt';
$raw_output = true;

$return = md5_file($filename, $raw_output);

$unpack = unpack('H*', $return);
$array_pop = array_pop($unpack);

echo $array_pop;

?>
8b1a9953c4611296a827abf8c47804d7

PHP