当前位置: 首页>>代码示例>>PHP>>正文


PHP Diff::compareFiles方法代码示例

本文整理汇总了PHP中Diff::compareFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Diff::compareFiles方法的具体用法?PHP Diff::compareFiles怎么用?PHP Diff::compareFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Diff的用法示例。


在下文中一共展示了Diff::compareFiles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

</pre>
            <table class="diff"><tr><th class="firstcolumns">F</th><th class="firstcolumns">S</th><th>Second File Output</th></tr></table>
            <div class="scrollingArea">
            <table class="diff">
            <?php 
        if (!$Diff->isAbsPath($_GET['first'])) {
            $_GET['first'] = WORKSPACE . '/' . $_GET['first'];
        }
        if (!$Diff->isAbsPath($_GET['second'])) {
            $_GET['second'] = WORKSPACE . '/' . $_GET['second'];
        }
        $oldindex = 0;
        $newindex = 0;
        $del = 0;
        $ins = 0;
        $diff = $Diff->compareFiles($_GET['first'], $_GET['second']);
        foreach ($diff as $key => $line) {
            echo '<tr>';
            if ($line[1] == 0) {
                $oldindex++;
                $newindex++;
                echo '<td class="linenumber firstcolumns">' . $oldindex . '</td><td class="linenumber firstcolumns">' . $newindex . '</td>';
                echo '<td class="diffUnmodified"><span>' . htmlspecialchars($line[0]) . '</span></td>';
            } else {
                if ($line[1] == -1) {
                    $oldindex++;
                    $del++;
                    echo '<td class="linenumber firstcolumns">' . $oldindex . '</td><td class="linenumber firstcolumns"></td>';
                    echo '<td class="diffDeleted"><span>' . htmlspecialchars($line[0]) . '</span></td>';
                } else {
                    if ($line[1] == 1) {
开发者ID:practico,项目名称:Codiad-DiffViewer,代码行数:31,代码来源:dialog.php

示例2: exec

 } else {
     for ($i = 0; $i < 5; $i++) {
         $final[$i] = "";
         exec("timeout 0.1s sh run.sh " . $b . ".c.out " . $testcase_i[$i], $output, $status);
         foreach ($output as $line) {
             $final[$i] .= "{$line}\n";
         }
         $output = "";
         if ($status == 124) {
             $response["testcase" . $i] = "Failed";
             $response["error"] = true;
             $response["message"] = "Timed Out";
         } else {
             $fileName = $b . "Output.txt";
             file_put_contents($fileName, $final[$i]);
             $diff = Diff::compareFiles($fileName, $testcase_o[$i]);
             if ($diff[0][1] == 0) {
                 if ($response["error"] == true) {
                     $response["error"] = true;
                 } else {
                     $response["error"] = false;
                 }
                 $response["testcase" . $i] = "Passed";
                 $response["message"] = "Success";
             } else {
                 $response["testcase" . $i] = "Failed";
                 $response["error"] = true;
                 $response["message"] = "Failure";
             }
         }
     }
开发者ID:karthicrajakumar,项目名称:interrupt-compiler,代码行数:31,代码来源:l.php

示例3: explode

<?php

require_once "diff_class.php";
$microstart = explode(' ', microtime());
$start_time = $microstart[0] + $microstart[1];
echo Diff::toString(Diff::compareFiles('old_char_346.xml', 'char_346.xml', false));
$microstop = explode(' ', microtime());
$stop_time = $microstop[0] + $microstop[1];
echo "Expired time: " . ($stop_time - $start_time) . "<br>";
echo "Memory load: " . memory_get_usage() . " bytes";
开发者ID:cls1991,项目名称:ryzomcore,代码行数:10,代码来源:diff_test.php

示例4: fopen

<?php

require_once 'class.Diff.php';
$target_dir = __DIR__ . "/uploads/";
$diff = Diff::compareFiles('old.txt', 'new.txt');
$newfile = fopen($target_dir . "changes.txt", "w") or die("Unable to open file!");
foreach ($diff as $line) {
    if ($line[1] === 2) {
        $array = explode("\t", $line[0]);
        fwrite($newfile, $array[2] . "\n");
    }
}
fclose($newfile);
echo "done";
开发者ID:sdsc,项目名称:itss-financial,代码行数:14,代码来源:differences.php

示例5: fopen

<?php

$email = $website_url = $handle = fopen("/opt/lampp/htdocs/{$email}/{$website_url}/change.txt", "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $pieces = explode(" ", $line);
        $variable1 = $pieces[0];
        if ($variable1 == "Files") {
            $variable2 = $pieces[1];
            $variable3 = $pieces[3];
            ob_start();
            require_once '/opt/lampp/htdocs/project/class.Diff2.php';
            $d = Diff::toTable(Diff::compareFiles("{$variable2}", "{$variable3}"));
            echo "<iframe src='http://localhost/left.html' width='49%' height='100%'></iframe>";
            echo "<iframe src='http://localhost/right.html' width='49%' height='100%'></iframe>";
            require_once '/opt/lampp/htdocs/project/class.Diff.php';
            $d = Diff1::toTable(Diff1::compareFiles("{$variable2}", "{$variable3}"));
            echo $d;
            $content = ob_get_contents();
            ob_end_clean();
            $variable2 = str_replace("/", ".", $variable2);
            $variable3 = str_replace("/", ".", $variable3);
            $search = ".opt.lampp.htdocs.{$email}.{$website_url}.";
            $variable2 = str_replace($search, '', $variable2);
            $variable3 = str_replace($search, '', $variable3);
            file_put_contents("/opt/lampp/htdocs/{$email}/{$website_url}/diff/{$variable2}.{$variable3}.html", $content);
        } else {
            $variable1 = $pieces[2];
            $variable2 = $pieces[3];
            $variable1 = str_replace(":", "/", $variable1);
            $output1 = "cp {$variable1}{$variable2} /opt/lampp/htdocs/{$email}/{$website_url}/diff/";
开发者ID:sky56,项目名称:Web_Page_Change_Notification_System,代码行数:31,代码来源:ch.php

示例6: create_file

                             echo $originalCodeFile . PHP_EOL . 'File do not exist' . PHP_EOL;
                             echo 'program could not check the code whether correct or not' . PHP_EOL;
                         }
                         echo "-----------------Diff show me the differ : ------------------\n";
                         $originalOPTB_WOCFile = ORIGIN_FILE_PATH . $path_parts['filename'] . '-objectcode.txt';
                         if (file_exists($originalOPTB_WOCFile)) {
                             $diffOPTB_WOC = Diff::compareFiles($originalOPTB_WOCFile, $OPTB_WOCtxtFile);
                             echo Diff::toString($diffOPTB_WOC);
                             create_file(RESULT_PATH . $OUTPUT_LOG_PREFIX . "diff-OPTB_WOC.html", Diff::toHTML($diffOPTB_WOC));
                             echo "\n";
                         } else {
                             echo $originalOPTB_WOCFile . "\n" . 'do not exist' . "\n";
                         }
                         $orignalObjectPFile = ORIGIN_FILE_PATH . $path_parts['filename'] . '-objectprogram.txt';
                         if (file_exists($orignalObjectPFile)) {
                             $diffObjectP = Diff::compareFiles($orignalObjectPFile, $obectProgramTxtFile);
                             echo Diff::toString($diffObjectP);
                             create_file(RESULT_PATH . $OUTPUT_LOG_PREFIX . "diff-ObjectProgram.html", Diff::toHTML($diffObjectP));
                             echo "\n";
                         } else {
                             echo $orignalObjectPFile . "\n" . 'do not exist' . "\n";
                         }
                         echo "-------------------------Diff end ----------------------------\n";
                         compare_array_in_html_js(RESULT_PATH . $OUTPUT_LOG_PREFIX . "compare_html_js.html", $OPTB_WOC, $orignalCode, "Compare Array", false);
                     }
                     ## end ## print out OPTB
                 }
             }
         }
     }
 }
开发者ID:BrokenPen,项目名称:SIC-XE-Assembler,代码行数:31,代码来源:sic.php


注:本文中的Diff::compareFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。