1. Go to this page and download the library: Download jblond/php-diff library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jblond / php-diff example snippets
use jblond\Diff;
use jblond\Diff\Renderer\Html\SideBySide;
// Installed via composer...
e(__FILE__).'/b.txt');
// Options for generating the diff.
$options = [
'ignoreWhitespace' => true,
'ignoreCase' => true,
'context' => 2,
'cliColor' => true, // for cli output
'ignoreLines' => Diff::DIFF_IGNORE_LINE_BLANK,
];
// Initialize the diff class.
$diff = new Diff($sampleA, $sampleB /*, $options */);
// Choose Renderer.
$renderer = new SideBySide([
'title1' => 'Custom title for sample A',
'title2' => 'Custom title for sample B',
]);
// Show the output of the difference renderer.
echo $diff->Render($renderer);
// Alternative
// Show the differences or a message.
echo $diff->isIdentical() ? 'No differences found.' : '<pre>' . htmlspecialchars($diff->render($renderer)) . '</pre>' ;