3 require_once( '../vendor/autoload.php' );
4 $html1 = "<p><i>This is</i> some sample text to <strong>demonstrate</strong> the capability of the <strong>HTML diff tool</strong>.</p>
5 <p>It is based on the <b>Ruby</b> implementation found <a href='http://github.com/myobie/htmldiff'>here</a>. Note how the link has no tooltip</p>
6 <table cellpadding='0' cellspacing='0'>
7 <tr><td>Some sample text</td><td>Some sample value</td></tr>
8 <tr><td>Data 1 (this row will be removed)</td><td>Data 2</td></tr>
11 <h2>Heading number one</h2>
12 <p>This paragraph will be deleted.</p>
13 <p>Another paragraph variant 1.</p>
14 <p>The last paragraph.</p>
23 <td>d1</td><td>d2</td>
25 <td>d3</td><td>d4</td>
27 <td>d5</td><td>d6</td>
33 <td>d1</td><td>d2</td>
35 <td>d3</td><td>d4</td>
37 <td>d5</td><td>d6</td>
41 $html2 = "<p>This is some sample <strong>text to</strong> demonstrate the awesome capabilities of the <strong>HTML <u>diff</u> tool</strong>.</p><br/><br/>Extra spacing here that was not here before.
42 <p>It is <i>based</i> on the Ruby implementation found <a title='Cool tooltip' href='http://github.com/myobie/htmldiff'>here</a>. Note how the link has a tooltip now and the HTML diff algorithm has preserved formatting.</p>
43 <table cellpadding='0' cellspacing='0'>
44 <tr><td>Some sample <strong>bold text</strong></td><td>Some sample value</td></tr>
46 Here is a number 2 <sup>32</sup>
47 <h2>Heading Number One</h2>
48 <p>Another paragraph variant 2.</p>
49 <p>The last paragraph.</p>
57 <td>d1</td><td>d2</td><td>d3</td>
59 <td>d5</td><td>d6</td><td>d4</td>
65 <td>d1</td><td>d2</td>
67 <td>d5</td><td>d6</td>
71 $diff = new HtmlDiffAdvanced();
72 $diff->setOldHtml($html1);
73 $diff->setNewHtml($html2);
74 echo "<h2>Old html</h2>";
75 echo $diff->getOldHtml();
76 echo "<hr><h2>New html</h2>";
77 echo $diff->getNewHtml();
78 echo "<hr><h2>Compared html</h2>";
79 echo $diff->getDifference();