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
- Using Cron Job to process PHP scripts
- job interview questions (1)
- PHP connect IBM db2 database in XAMPP
- Set up a child account and set screen time limit in Windows 8
- Datatable export excel wraptext and newline
- Install PHPMailer 5.2.4 and use smtp gmail
- PHP - Export Content to MS Word document
- Powerful js library datable to export table in pdf, excel, sorting, freezing column and table header fixed (sticky)
- Sweet Alert JS library - beautiful replacement of JavaScript Alert
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