PHP - xdiff file_diff() 函式



xdiff_file_diff() 函式可以生成兩個檔案的統一 diff。

語法

bool xdiff_file_diff( string $old_file , string $new_file , string $dest [, int $context = 3 [, bool $minimal = false ]] )

xdiff_file_diff() 函式可以生成一個統一的 diff,其中包含 old_file 和 new_file 之間的差異,並將其儲存在 dest 檔案中。生成的 diff 檔案是人類可讀的,可選的 context 引數指定在每個更改周圍新增多少行上下文。將 minimal 引數設定為 true 可以生成儘可能短的補丁檔案(可能需要很長時間)。

xdiff_file_diff() 函式在成功時返回 true,失敗時返回 false。

xdiff_file_diff() 函式不適用於二進位制檔案。要生成二進位制檔案的 diff,請使用 xdiff_file_bdiff()/xdiff_file_rabdiff() 函式。

示例

<?php
   $old_version = "my_script.php";
   $new_version = "my_new_script.php";

   xdiff_file_diff($old_version, $new_version, "my_script.diff", 2);
?>
php_function_reference.htm
廣告