• PHP Video Tutorials

PHP - xdiff Functions



xdiff extension can enable us to create and apply patch files containing differences between different revisions of files.

This extension can support two modes of operation: on strings and on files, as well as two different patch formats: unified and binary. The unified patches are excellent for text files as they are human-readable and easy to review. For binary files: archives or images, the binary patches can be an adequate choice as they are binary safe and handle non-printable characters.

Starting from version 1.5.0, there are two different sets of functions to generate binary patches. The new functions: xdiff_string_rabdiff() and xdiff_file_rabdiff() can generate output compatible with older functions but are typically faster and generate smaller results.

This extension can use libxdiff to implement these functions.

Predefined Constants

The constants are defined below by this extension and can be available only when an extension has either compiled into PHP or dynamically loaded at runtime.

  • XDIFF_PATCH_NORMAL (integer) − This flag indicates that xdiff_string_patch() and xdiff_file_patch() functions should create result by applying patch to original content thus creating newer version of file. This is the default mode of operation.
  • XDIFF_PATCH_REVERSE (integer) − This flag indicated that xdiff_string_patch() and xdiff_file_patch() functions should create result by reversing patch changed from newer content thus creating original version.
Sr.No Function & Description
1 xdiff_file_bdiff()

Function can make a binary diff of two files.

2 xdiff_file_bdiff_size()

Function can read the size of a file created by applying a binary diff.

3 xdiff_file_bpatch()

Function can patch a file with a binary diff.

4 xdiff_file_diff()

Function can make a unified diff of two files.

5 xdiff_file_diff_binary()

Function can make a binary diff of two files.

6 xdiff_file_merge3()

Function can merge three files into one..

7 xdiff_file_patch()

Function can patch a file with an unified diff.

8 xdiff_file_patch_binary()

Function is an alias of xdiff_file_bpatch().

9 xdiff_file_rabdiff()

Function can make a binary diff of two files by using Rabin's polynomial fingerprinting algorithm.

10 xdiff_string_bdiff()

Function can make a binary diff of two strings.

11 xdiff_string_bdiff_size()

Function can read the size of a file created by applying a binary diff.

12 xdiff_string_bpatch()

Function can patch a string with binary diff.

13 xdiff_string_diff()

Function can make a unified diff of two strings.

14 xdiff_string_diff_binary()

Function is an alias of xdiff_string_bdiff().

15 xdiff_string_merge3()

Function can merge three strings into one.

16 xdiff_string_patch()

Function can patches a string with an unified diff.

17 xdiff_string_patch_binary()

Function is an alias of xdiff_string_bpatch().

18 xdiff_string_rabdiff()

Function can make a binary diff of two strings by using Rabin's polynomial fingerprinting algorithm.

php_function_reference.htm
Advertisements