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 ));}}}}}