Jump to content

GeSHi Code Formatter


emcgfx

Recommended Posts

Hey guys, I'm trying to figure out on how to add line numbers and odd/even colors to my code. Please help.

 

<?php
//
// Include the GeSHi library//
include_once 'geshi/geshi.php'; 

//// Define some source to highlight, a language to use
// and the path to the language files//
$source = '$foo = 45;
for ( $i = 1; $i < $foo; $i++ ){
  echo "$foo\n";  --$foo;
}';

$language = 'php';

// Create a GeSHi object//
$geshi = new GeSHi($source, $language);
$geshi->start_line_numbers_at(1);
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
$geshi->set_line_style('background: #fcfcfc;', 'background: #f0f0f0;');

// And echo the result!//
echo $geshi->parse_code();

?>

 

As you can see I've defined this lines to enable this function. But still not working. Yes geshi.php and needed files included properly, if you are wondering :) Thanks.

Link to comment
https://forums.phpfreaks.com/topic/162228-geshi-code-formatter/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.