What are some best practices for using geshi in PHP to highlight code snippets effectively?

When using GeSHi in PHP to highlight code snippets effectively, it is important to properly configure the language and output format to match the code being highlighted. Additionally, make sure to sanitize any user input to prevent potential security vulnerabilities. Finally, consider caching the highlighted code to improve performance.

// Example of using GeSHi to highlight a code snippet
$code = "<html><body><h1>Hello, World!</h1></body></html>";
$language = "html";
$geshi = new GeSHi($code, $language);
$geshi->enable_classes();
$highlightedCode = $geshi->parse_code();
echo $highlightedCode;