What are the best practices for applying syntax highlighting to HTML code in PHP?

When applying syntax highlighting to HTML code in PHP, it is best practice to use a library or tool specifically designed for this purpose, such as GeSHi or highlight.js. These libraries make it easy to add syntax highlighting to HTML code by providing predefined styles and functions to apply the highlighting. By using these tools, you can ensure consistent and visually appealing syntax highlighting in your PHP applications.

// Example using GeSHi library for syntax highlighting
require_once('geshi/geshi.php');

$htmlCode = '<html><head><title>Example</title></head><body><h1>Hello World!</h1></body></html>';

$geshi = new GeSHi($htmlCode, 'html');
echo $geshi->parse_code();