xdiff_string_diff() 函數可以對兩個字符串進行統一的diff。
用法
string xdiff_string_diff( string $old_data , string $new_data [, int $context = 3 [, bool $minimal = false ]] )
xdiff_string_diff() 函數可以對 old_data 字符串和 new_data 字符串之間的差異進行統一的 diff 並返回。由此產生的差異可以是人類可讀的。一個可選的上下文參數可以指定在每次更改周圍添加了多少行上下文。將最小參數設置為 true 可能會導致輸出最短的補丁文件(可能需要很長時間)。
如果發生內部錯誤,xdiff_string_diff() 函數可以返回帶有結果差異或假的字符串。
示例
<?php
$old_article = file_get_contents("./old_article.txt");
$new_article = $_REQUEST["article"];
$diff = xdiff_string_diff($old_article, $new_article, 1);
if(is_string($diff)) {
echo "Differences between two articles:\n";
echo $diff;
}
?>
相關用法
- PHP xdiff_string_rabdiff()用法及代碼示例
- PHP xdiff_string_patch()用法及代碼示例
- PHP xdiff_file_diff_binary()用法及代碼示例
- PHP xdiff_file_rabdiff()用法及代碼示例
- PHP xdiff_file_bdiff()用法及代碼示例
- PHP xdiff_file_patch_binary()用法及代碼示例
- PHP xdiff_file_bpatch()用法及代碼示例
- PHP xdiff_file_diff()用法及代碼示例
- PHP xdiff_file_patch()用法及代碼示例
- PHP xmlwriter_end_dtd_attlist()用法及代碼示例
- PHP xmlwriter_end_dtd_element()用法及代碼示例
- PHP xml_get_current_column_number()用法及代碼示例
- PHP xmlwriter_write_dtd()用法及代碼示例
- PHP xmlwriter_full_end_element()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - xdiff string_diff() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。