1

Is there a functional String Difference Highlighting class/function out there for PHP?

This has been asked before Highlight the difference between two strings in PHP but the answers given suggest PEAR's Text_Diff.

I tried using Text_Diff and found it was giving me a bunch of STRICT NOTICES and the examples given returned empty strings.

Errors like:

array_walk() expects parameter 2 to be a valid callback, non-static method Text_Diff::trimNewlines() should not be called statically
Community
  • 1
  • 1
Ian
  • 24,116
  • 22
  • 58
  • 96

3 Answers3

1

Open '/framework/gii/components/Pear/Text/Diff.php' file. Locate the function trimNewlines and add a word static. Something like this:

static function trimNewlines(&$line, $key)

This may help.

willowdan
  • 3
  • 2
Girish
  • 11
  • 1
0

I think it means that one or more of the functions that PEAR package uses is not backward compatible with some earlier version(s) of PHP. Maybe just suppress the notice using error_reporting or (dare I say) with the error suppression operator '@'.

karim79
  • 339,989
  • 67
  • 413
  • 406
  • I'm using PHP 5.3 and the errors are for things like: "array_walk() expects parameter 2 to be a valid callback, non-static method Text_Diff::trimNewlines() should not be called statically" – Ian Sep 16 '09 at 03:03
0

You could contact the maintainer of Text_Diff and report the errors. 5.3 is relatively new and it introduces a bunch of changes, so there are many projects that haven't been upgraded yet.

troelskn
  • 115,121
  • 27
  • 131
  • 155