• PHP Video Tutorials

PHP - xdiff file_diff() Function



xdiff_file_diff() function can make a unified diff of two files.

Syntax

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

xdiff_file_diff() function can make a unified diff containing differences between old_file and new_file and store it in dest file. The resulting file is human-readable, and an optional context parameter specifies how many lines of context have added around each change. Setting the minimal parameter to true that result in outputting the shortest patch file possible (can take a long time).

xdiff_file_diff() function can return true on success or false on failure.

xdiff_file_diff() function doesn't work well with the binary files. To make diff of binary files, then use xdiff_file_bdiff()/xdiff_file_rabdiff() function.

Example

<?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
Advertisements