-
-
Save parzibyte/30a7197ba5c21acc537381ca19c6f05f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fichero1 = "fichero1.txt"; | |
$fichero2 = "fichero2.txt"; | |
$contenidoFichero1 = file_get_contents($fichero1); | |
$contenidoFichero2 = file_get_contents($fichero2); | |
$tamanioFichero1 = strlen($contenidoFichero1); | |
$tamanioFichero2 = strlen($contenidoFichero2); | |
$resultado = ""; | |
if ($tamanioFichero1 === $tamanioFichero2 && $contenidoFichero1 === $contenidoFichero2) { | |
$resultado = "TAMAÑO IGUAL\nTamaño: " . $tamanioFichero1 . " bytes\nCONTENIDO IGUAL\nContenido 1 y 2: " . $contenidoFichero1; | |
} else if ($tamanioFichero1 === $tamanioFichero2 && $contenidoFichero1 !== $contenidoFichero2) { | |
$resultado = "TAMAÑO IGUAL\nTamaño: " . $tamanioFichero1 . " bytes\nCONTENIDO DIFERENTE\nContenido 1: " . $contenidoFichero1 . "\nContenido 2: " . $contenidoFichero2; | |
} else { | |
$resultado = "TAMAÑO DIFERENTE\nTamaño: " . $tamanioFichero1 . "bytes - " . $tamanioFichero2 . "bytes\nCONTENIDO DIFERENTE\nContenido 1: " . $contenidoFichero1 . "\nContenido 2: " . $contenidoFichero2; | |
} | |
# Escribir el resultado en el archivo de salida | |
file_put_contents("resultado.txt", $resultado); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment