Discussion: Comparing files
Afficher un message
Vieux 12/03/2008, 13h09   #4
Aschwin Wesselius
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Comparing files

mathieu leddet wrote:
> 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));
>
> }

I would say, use a md5 checksum on both files:


function files_identical($path1, $path2) {

return (md5(file_get_contents($path1)) === md5(file_get_contents($path2)));

}



--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

  Réponse avec citation
 
Page generated in 0,06363 seconds with 9 queries