PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Philipp Strazny   PHP String Diff Class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: usage examples: English, Chinese, Russian, Thai characters
Class: PHP String Diff Class
Compare and find differences between two strings
Author: By
Last change:
Date: 11 years ago
Size: 2,413 bytes
 

Contents

Class file image Download
<html>
<body>
<?php
include('StringDiff.php');
print
StringDiff::getCSS();
$a = 'This is a string.';
$b = 'This would be another string.';
print
'<table>';
print
'<tr><td colspan=2>English characters:</td></tr>';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'<tr></tr>';
print
'<tr><td colspan=2>Chinese characters:</td></tr>';
$a = '??????? ???????';
$b = '??????? ?????????';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'<tr></tr>';
print
'<tr><td colspan=2>Russian characters:</td></tr>';
$a = '??????????? ???????? ???? ?? ??????????? ????????? ?????? ';
$b = '??????????? ??????? ???? ? ??????';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'<tr></tr>';
print
'<tr><td colspan=2>Thai characters:</td></tr>';
$a = '?????????????? \'??????? ???.\' ????? \'?????????\' ???? \'???????\'';
$b = '?????????????? \'??????? .\' ????? \'?????????\' ???? \'??????????\'';
print
'<tr><td>a:</td><td>'.$a.'</td></tr>';
print
'<tr><td>b:</td><td>'.$b.'</td></tr>';
print
'<tr><td>diff:</td><td>'.StringDiff::diff($a, $b).'</td></tr>';
print
'<tr><td>overlap in a:</td><td>'.StringDiff::overlap($a, $b).'</td></tr>';
print
'<tr><td>overlap in b:</td><td>'.StringDiff::overlap($b, $a).'</td></tr>';
print
'</table>';


?>
</body>
</html>