Re: Comparing files
| From: | Thijs Lensselink | Date: | Wed, 12 Mar 2008 11:08:50 +0000 |
| Subject: | Re: Comparing files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271340@lists.php.net to get a copy of this message | ||
Quoting mathieu leddet <mathieu.leddet@mobilescope.com>:
Hi all, I have a simple question : how can I ensure that 2 files are identical ? How about this ? --------8<------------------------------------------------------ function files_identical($path1, $path2) { return (file_get_contents($path1) == file_get_contents($path2)); } --------8<------------------------------------------------------ Note that I would like to compare any type of files (text and binary). Thanks for any help, -- MathieuYou could use "md5_file" for this. Something like: function files_identical($path1, $path2) { return (md5_file($path1) == md5_file($path2)); }