Login   Register  
PHP Classes
elePHPant
Icontem

File: demo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of tony  >  Safe keyword highlight  >  demo.php  >  Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: Example that shows an HTML text with and without highlighting
Class: Safe keyword highlight
Text keyword highlight within HTML tags
Author: By
Last change: new relese
Date: 11 years ago
Size: 1,690 bytes
 

Contents

Class file image Download
<?
/**********************************************************************************************
 * DEMO for highlighter.php CLASS by Bojidar Naydenov a.k.a Bojo (bojo2000@mail.bg) & Antony Raijekov a.k.a Zeos (dev@strategma.bg)
 **********************************************************************************************
 * This class highlights text matches a search string (keyword) in html based documents, without destroying html-tags. 
 * This was necessary to scan database-entry written in html by keywords, and display them in another style.
 **********************************************************************************************/

    
include("highlighter.class.php");    //include class

/********************************************************************************************
 * DEMO code
 ********************************************************************************************/    
// assume $text is content of article ot some other text
    
$text "<div>text <table>
    <tr>
        <td valign=top> <IMG src=\"http://aces.ee.olemiss.edu/images/test.gif\" title=\"test\">
    </tr>
    </table> <B>test</B> text <a href=\"test.php\">tester</a> <A HREF=\"index.php?seek=test\" style=\"color:green\">test is tester but is not good</A> text.Test.</div>"
;

//create hightlight instance class, with keyword(test) and replacement (<u>{keyword}</u>)
//NOTE: the {keyword} in second argument (replacement) is alias for matching keyword.
    
$h = new highlight ('test','<u style="background-color:#B5B5B5">{keyword}</u>');             
//print original text
    
print $text;
    print 
"<hr>";

//print it proceed with hightlight
    
print $h->process($text);
    print 
"<hr>";

?>