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


PHP Diff::toString方法代码示例

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


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

示例1: 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

示例2: get_test_result

function get_test_result($name, $verbose = false, $moreVerbose = false)
{
    $mergeSpace = IGNORE_INDENT && strpos($name, 'indent.') === false;
    $path = TEMPLATES_DIRECTORY . DIRECTORY_SEPARATOR . $name;
    $expectedHtml = @file_get_contents($path . '.html');
    if ($expectedHtml === false) {
        if ($verbose) {
            echo "! sample for test '{$name}' not found.\n";
        }
        return array(false, array($name, null, "! sample for test '{$name}' not found.\n"));
    }
    if ($verbose) {
        echo "* rendering test '{$name}'\n";
    }
    try {
        $new = get_php_code($path . '.jade');
    } catch (Exception $err) {
        if ($verbose) {
            echo "! FATAL: php exception: " . str_replace("\n", "\n\t", $err) . "\n";
        }
        return array(false, array($name, null, "! FATAL: php exception: " . str_replace("\n", "\n\t", $err) . "\n"));
    }
    if (is_null($new)) {
        return array(false, array($name, null, "! FATAL: " . $path . ".jade returns null\n"));
    }
    $actualHtml = get_generated_html($new);
    $from = array("'", "\r", "<!DOCTYPEhtml>");
    $to = array('"', '', '');
    if ($mergeSpace) {
        array_push($from, "\n", "\t", " ");
        array_push($to, '', '', '');
    }
    $expectedHtml = preg_replace_callback('`class\\s*=\\s*(["\'])([^"\']+)\\1`', 'orderWords', $expectedHtml);
    $actualHtml = preg_replace_callback('`class\\s*=\\s*(["\'])([^"\']+)\\1`', 'orderWords', $actualHtml);
    if ($mergeSpace) {
        $expectedHtml = preg_replace('`(?<=[\'"])\\s(?=>)|(?<=[a-zA-Z0-9:])\\s(?=(>|\\s[a-zA-Z0-9:]))`', '', $expectedHtml);
        $actualHtml = preg_replace('`(?<=[\'"])\\s(?=>)|(?<=[a-zA-Z0-9:])\\s(?=(>|\\s[a-zA-Z0-9:]))`', '', $actualHtml);
    }
    $minifiedExpectedHtml = str_replace($from, $to, trim($expectedHtml));
    $minifiedActualHtml = str_replace($from, $to, trim($actualHtml));
    $result = array($name, $minifiedExpectedHtml, $minifiedActualHtml);
    if (strcmp($minifiedExpectedHtml, $minifiedActualHtml)) {
        if ($verbose) {
            include_once __DIR__ . '/diff.php';
            $actualHtml = preg_replace('`(\\r\\n|\\r|\\n)([\\t ]*(\\r\\n|\\r|\\n))+`', "\n", $actualHtml);
            $expectedHtml = preg_replace('`(\\r\\n|\\r|\\n)([\\t ]*(\\r\\n|\\r|\\n))+`', "\n", $expectedHtml);
            echo Diff::toString(Diff::compare($expectedHtml, $actualHtml)) . "\n";
            /*
            echo "  Expected: $expectedHtml\n";
            echo "  Actual  : $actualHtml\n\n";
            */
        }
        if ($moreVerbose) {
            echo "  PHP     : " . compile_php($name);
        }
        return array(false, $result);
    }
    return array(true, $result);
}
开发者ID:kylekatarnls,项目名称:jade-php,代码行数:59,代码来源:bootstrap.php

示例3: create_file

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