Use php to lose the md5 check value of the folder

Source: Internet
Author: User
Use php to get the md5 check value of the folder & lt ;? The ultimate goal of the php *** tool file is to compare the differences between the two folders. ** However, this program is only used to get the md5 checksum of one directory, so it needs to be executed on different machines separately, then compare the md5 checksum ** 1) Call example * phpget_folder_md5.phphometemp2 ** 2) I don't want to get the md5 checksum value of the folder than using php
 1) $ dir1 = del_postfix ($ argv [1]); else die ('Please input dir'); $ global_str = md5 ('1 '); // check whether the first path has a method that does not exist or is incorrect. Get_folder_md5 ($ dir1 ); echo "============================================== =====================================\ n "; echo $ global_str; echo "\ n";/*** remove/at the end of the path /, make sure the path is absolute ** @ param unknown_type $ dir * @ return unknown */function del_postfix ($ dir) {if (! Preg_match ('# ^/#', $ dir) {throw new Exception ('The parameter must be an absolute path');} $ dir = preg_replace ('#/$ #', '', $ dir); return $ dir;}/*** recursive call to obtain md5 ** @ param string $ dir1 path 1, which is standard */function get_folder_md5 ($ dir1) {global $ global_str; if (is_dir ($ dir1) {$ arr = scandir ($ dir1); foreach ($ arr as $ entry) {if ($ entry! = ".") & ($ Entry! = "...") & ($ Entry! = ". Svn ") {$ new = $ dir1 ."/". $ entry; // $ new is the complete file name or folder name // If you do not want to display the file name, you can comment out the following echo $ entry. "\ n"; $ global_str = md5 ($ global_str. $ entry); if (is_dir ($ new) {get_folder_md5 ($ new);} else {$ global_str = md5 ($ global_str. md5_file ($ new ));}}}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.