RE: [PHP] Comparing files
| From: | Edward Kay | Date: | Wed, 12 Mar 2008 11:13:11 +0000 |
| Subject: | RE: [PHP] Comparing files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271343@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: mathieu leddet [mailto:mathieu.leddet@mobilescope.com]
> Sent: 12 March 2008 11:04
> To: php-general@lists.php.net
> Subject: [PHP] Comparing files
>
>
> 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,
>
Depending upon the size of the files, I would expect it would be quicker to
compare a hash of each file.
Edward