Code Search for Developers
 
 
  

diff.php from ECP (EliteCore Project) at Krugle


Show diff.php syntax highlighted

#!/usr/local/bin/php
<?php
/**
 * Text_Diff example script.
 *
 * Take two files from the command line args and produce a unified
 * diff of them.
 *
 * @package Text_Diff
 */

include_once 'Text/Diff.php';
include_once 'Text/Diff/Renderer.php';
include_once 'Text/Diff/Renderer/unified.php';

/* Make sure we have enough arguments. */
if (count($argv) < 3) {
    echo "Usage: diff.php <file1> <file2>\n\n";
    exit;
}

/* Make sure both files exist. */
if (!is_readable($argv[1])) {
    echo "$argv[1] not found or not readable.\n\n";
}
if (!is_readable($argv[2])) {
    echo "$argv[2] not found or not readable.\n\n";
}

/* Load the lines of each file. */
$lines1 = file($argv[1]);
$lines2 = file($argv[2]);

/* Create the Diff object. */
$diff = &new Text_Diff($lines1, $lines2);

/* Output the diff in unified format. */
$renderer = &new Text_Diff_Renderer_unified();
echo $renderer->render($diff);




See more files for this project here

ECP (EliteCore Project)

EliteCore Project is a PHP5.1/Javascript/AJAX/XHTML/CSS framework for creating WEB 2.0 applications and services.The basic open-source instalation can be also used as an interactive personal page or BLOG.This project uses the latest features available.

Project homepage: http://sourceforge.net/projects/elitecore
Programming language(s): JavaScript,PHP,XML
License: cpl

  1.txt
  2.txt
  diff.php