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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.