Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHPWind-- A PHP forum script applcaition in China
- How to blend adsense inside your post?
- Formatting my post
- Notepad++ - Add C++ compiler
- Install PHPMailer 5.2.4 and use smtp gmail
- Set up a child account and set screen time limit in Windows 8
- Wayback Machine - see archived versions of web pages across time
- phpexcel toggle expand and hide column in EXCEL and summary
- Install PHP ibm_db2 extension in Linux (redHat)
- PHP: add a download as pdf file button in report page
Thursday, September 13, 2012
PHP, check if a file is modified using md5_file
To check if a file is modified in PHP, we use md5 algorithm and PHP function md5_file() function
1) First, we store the file for example " test.txt" md5 in md5test.txt using PHP function md5_file
<?php
$md5file = md5_file("test.txt");
file_put_contents("md5test.txt",$md5file);
?>
2) As the time goes by, we can compare the md5 of the file to the md5 stored.
<?php
$md5file = file_get_contents("md5test.txt");
if (md5_file("test.txt") == $md5file)
{
echo "The file test.txt does not change.";
}
else
{
echo "The file test.txt has been changed.";
}
?>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment