GeSHi is a syntax highlighter for PHP that allows you to highlight and display source code in web pages. To enable or disable line numbers in GeSHi, you can use the enable_line_numbers
method.
Here is an example of how you can enable line numbers in GeSHi:
<?php // Include the GeSHi library include 'geshi.php'; // Create a new GeSHi object $geshi = new GeSHi('<?php echo "Hello, world!"; ?>', 'php'); // Enable line numbers $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); // Display the highlighted code echo $geshi->parse_code();
This will enable line numbers in the highlighted code, using the GESHI_FANCY_LINE_NUMBERS
style.
To disable line numbers in GeSHi, you can pass the GESHI_NO_LINE_NUMBERS
constant to the enable_line_numbers
method:
<?php // Include the GeSHi library include 'geshi.php'; // Create a new GeSHi object $geshi = new GeSHi('<?php echo "Hello, world!"; ?>', 'php'); // Disable line numbers $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS); // Display the highlighted code echo $geshi->parse_code();
This will disable line numbers in the highlighted code.
Overall, the enable_line_numbers
method is a useful tool for enabling or disabling line numbers in GeSHi. It allows you to customize the appearance of the highlighted code and control whether line numbers are displayed or not.