Welcome Guest, Not a member yet? Register   Sign In
Code highlighting
#1

[eluser]Arun Joshi[/eluser]
Hi All

I would like to start my personal blog in codeigniter. There I have a lot of php code to display. So I want to highlight the php codes on each posts. I like the CI forum code highligthing very much. Is CI providing any libraries or methods for this?

Code:
function show()
{
echo "I like to highlight my code like this. ";

}

Thanks :-)
#2

[eluser]Jamie Rumbelow[/eluser]
You sure can! It's in the Text Helper:

Code:
$this->load->helper('text');

highlight_code('Mmmm, some nice code to highlight');

Jamie
#3

[eluser]überfuzz[/eluser]
There's always the core library: highlight_string
#4

[eluser]Arun Joshi[/eluser]
How can we specify colors?
#5

[eluser]rogierb[/eluser]
dude, did you read the userguide?

Quote:highlight_code()

Colorizes a string of code (PHP, HTML, etc.). Example:
$string = highlight_code($string);

The function uses PHP's highlight_string() function, so the colors used are the ones specified in your php.ini file.
#6

[eluser]Phil Sturgeon[/eluser]
Here is a very decent library that acts for a wrapper to GeSHI.

http://shivercube.com/programming/php/co...r-library/




Theme © iAndrew 2016 - Forum software by © MyBB