0
我已閱讀並嘗試過所有答案here,但它們似乎只適用於非二進制格式的字符串。我想比較二進制文件的差異,並返回那些格式,如這樣的:用PHP返回二進制文件中的十六進制差異
[file1]
-0001010: ac 0f 00 00 01 00 00 00 48 65 6c 6c 6f 2c 20 77 ........Hello, w
[file2]
+0001010: ac 0f 00 00 01 00 00 00 48 75 6c 6c 6f 2c 20 77 ........Hullo, w
xdiff
工作正常創建則bdiff補丁和補丁文件 - 我期待太多說明的差異。
$one = 'one'; // original file
$two = 'two'; // updated file
$pat = 'dif'; // bdiff patch
$new = 'new'; // new destfile
xdiff_file_diff_binary($one, $two, $pat);
xdiff_file_patch_binary($one, $pat, $new);
$diff = xdiff_file_diff($one, $two, 1);
if (is_file($diff)) {
echo "Differences:\n"; // result = 1
echo $diff;
}
也許xdiff
是不是正確的擴展名是用於此?我不確定。
不錯的想法,但是當我嘗試使用它與'exec()'例如我得到一個錯誤:'sh:-c:line 0:語法錯誤附近的意外令牌'''' – Devon 2014-10-07 01:25:00
@Devon因爲它是* bash *單行,並且你的系統默認爲''sh'作爲'exec()'。 – Sammitch 2014-10-07 16:40:13