Store the MD5 hash of "test.txt" in a file in PHP
Description
The following code shows how to store the MD5 hash of "test.txt" in a file.
Example
/* w ww .ja va 2 s . c o m*/
<?php
$md5file = md5_file("test.txt");
file_put_contents("md5file.txt",$md5file);
//Test if "test.txt" has been changed (that is if the MD5 hash has been changed)
$md5file = file_get_contents("md5file.txt");
if (md5_file("test.txt") == $md5file){
echo "The file is ok.";
}else{
echo "The file has been changed.";
}
?>
The code above generates the following result.