there aren't any built in diff functions in PHP. but, hooray for PEAR: Text_Diff (never used it tough, but in PEAR i trust).
and there's even a PECL package, xdiff
hint: pear classes are pure php, pecl packages are modules. normally, modules are faster than classes, but it also depends on the functionality. you just have to test and evaluate.
for storing: i'd store the plain text, not the diffs. space is cheap, many databases (e.g. mysql) support data compression (or you could de/compress in php), but if you store the plaintext, you're independent of the diff algorithm and can change it later if needed.
if you need speed, you could store both the plaintexts AND the diffs.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…