略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: xdiff 函数

2024-04-30

xdiff 函数

目录

add a noteadd a note

User Contributed Notes 1 note

up
3
amir.laher
17 years ago
the xdiff functions require your initial string to end with a \n character.

When you use xdiff_string_diff, the initial string must either be zero-length or end with \n
eg. $patch= xdiff_string_diff($string,$string2);

if not, the patch will return an empty string.
xdiff_string_patch($string,$patch);

This will not normally affect xdiff_file_diff, but it's annoying nevertheless. To prevent this unexpected effect, I append a \n to the string before applying the initial diff, as follows.
if (!ereg("\n$",$string)) $string.="\n";

官方地址:https://www.php.net/manual/en/ref.xdiff.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3