Codeigniter + Geshi

Geshi is a PHP class to do the heavy lifting for syntax highlighting output to your browswer. Geshi started originally to help users highlight code posted on bulletin board sites. I converted the standard Geshi class into a Codeigniter library. Just a simple as renaming the class and created a few methods to conform to some of the options you’ll find in codeigniter.

Download Codeigniter Geshi Library

Here’s how you will use this library in Codeigniter. First, extract the zip file and place the contents into your /application/libraries folder within your codeigniter folder structure.

Example code:

$this->load->library('geshi'); //load geshi class
$config['set_language'] = 'php'; //REQUIRED set language to parse
$config['set_source'] = 'foreach($test as $item){ echo "hello";}'; //REQUIRED set source code to parse
echo $this->geshi->output(); //output from geshi alias of parse_code

You can pass any geshi method or variable in the config array. Just name the key the same as the method or variable you are setting, and the value to what you would like to pass.