PHP Classes

Simple PHP Syntax Highlighting: Highlight words in a HTML text with a given color

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 82 All time: 10,085 This week: 488Up
Version License PHP version Categories
simplesyntaxhighligh 1.0.0The PHP License5HTML, PHP 5, Text processing
Description 

Author

This is a very simple class that can highlight words in a HTML text with a given color.

It takes a given text as parameter and finds a given word in the text.

The class replaces the word by HTML tags that show the same word in a given color, which by default will be yellow.

Picture of Mr. Dharmendra Kumar
  Performance   Level  
Name: Mr. Dharmendra Kumar <contact>
Classes: 8 packages by
Country: India India
Innovation award
Innovation award
Nominee: 1x

Example

<?php
//Include require class;
require_once("SimpleSyntaxHighlighter.php");
$simple=new SimpleSyntaxHighlighter;


$match='Boat pistol bicycle grenade post-tank-traps table tanto neon rifle spook bomb sign drugs. Girl 3D-printed faded tattoo office systemic military-grade j-pop corrupted drone pen warehouse free-market camera engine hacker tanto';
$syntax='Construct denim savant rifle ablative alcohol apophenia katana. Receding assault augmented reality spook Chiba advert alcohol Shibuya decay industrial grade carbon. Singularity savant vinyl saturation point warehouse faded dissident sunglasses film assault claymore mine bridge post. Marketing shrine semiotics sentient cardboard jeans neural bomb motion BASE spook convenience store dissident towards shoes Kowloon. Tank-traps convenience store San Francisco girl render-farm j-pop otaku boy claymore mine grenade cartel. Boat pistol bicycle grenade post-tank-traps table tanto neon rifle spook bomb sign drugs. Girl 3D-printed faded tattoo office systemic military-grade j-pop corrupted drone pen warehouse free-market camera engine hacker tanto. ';

$color="Yellow";


echo
$simple->HighlightThis($match,$syntax, $color);

?>



Details

SimpleSyntaxHighlighter

SimpleSyntaxHighlighter is a PHP class that can highlight syntax as well as word given by user.

How to use

<?php //Include require class; require_once("SimpleSyntaxHighlighter.php"); $simple=new SimpleSyntaxHighlighter;

$match='Boat pistol bicycle grenade post-tank-traps table tanto neon rifle spook bomb sign drugs. Girl 3D-printed faded tattoo office systemic military-grade j-pop corrupted drone pen warehouse free-market camera engine hacker tanto'; $syntax='Construct denim savant rifle ablative alcohol apophenia katana. Receding assault augmented reality spook Chiba advert alcohol Shibuya decay industrial grade carbon. Singularity savant vinyl saturation point warehouse faded dissident sunglasses film assault claymore mine bridge post. Marketing shrine semiotics sentient cardboard jeans neural bomb motion BASE spook convenience store dissident towards shoes Kowloon. Tank-traps convenience store San Francisco girl render-farm j-pop otaku boy claymore mine grenade cartel. Boat pistol bicycle grenade post-tank-traps table tanto neon rifle spook bomb sign drugs. Girl 3D-printed faded tattoo office systemic military-grade j-pop corrupted drone pen warehouse free-market camera engine hacker tanto. ';

$color="Yellow";

echo $simple->HighlightThis($match,$syntax, $color);

?>


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file howtouse.php Example Example script
Accessible without login Plain text file README.md Doc. Read me
Plain text file SimpleSyntaxHighlighter.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:82
This week:0
All time:10,085
This week:488Up