Question:
Tutorial explaining how to write a diff script in PHP?
GermanGeek
2007-10-14 06:11:43 UTC
Hi all!

I'm desperately looking for a (free) tutorial explaining how all those diff.php files work. What's happening in the background? What would one have to do to write one's own script diffing two chunks of text?

Basically, I'm looking for an explanation of how those "version history compare utilities" of wikis work...

Kind regards,

Christian
Three answers:
2007-10-14 08:27:17 UTC
I'm not entirely clear on what you are asking, but I can offer some basics.



The easiest way to compare two strings in PHP is with strcmp():

http://us3.php.net/manual/en/function.strcmp.php



It makes what is called a "binary-safe" string comparison. What that means is that if you use strcmp, it looks at the binary values of the strings -- not what physically appears on the screen -- and sees if they are exactly the same values.



Another effective way to compare strings is with hashes -- short codes that can be generated to compare the values of two strings or two files.



Most commonly, that's done with the MD5 hash algorithm:

http://us3.php.net/manual/en/function.md5.php

http://us3.php.net/manual/en/function.md5-file.php



In the case of wikis, their DB storage engines generally handle watching the changes and storing them; by storing each revision as a record in the database, you can easily track changes across the lifetime of an article.



You can see how MediaWiki (Wikipedia) does this here:

http://www.mediawiki.org/wiki/Revision_table
2016-10-09 09:02:08 UTC
In a Hypertext Preprocessor report you do no longer prefer and HTML tags and in a HTML report you do no longer prefer and Hypertext Preprocessor tags. e.g. although you need to use Hypertext Preprocessor interior HTML tags: html head d5d3db1765287eef77d7927cc956f5aHello Worldd5d3db1765287eef77d7927cc956f5a head physique physique html
hi
2007-10-14 15:39:18 UTC
this site will direct you to free tutorial site, it could helps you

http://freecourses.8m.com/php.htm

good luck


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...