How can HTML source code be displayed with automatic color coding on a webpage using PHP?

To display HTML source code with automatic color coding on a webpage using PHP, you can use the highlight_string() function in PHP. This function takes a string of PHP code as input, highlights it with different colors based on syntax, and then outputs it to the webpage.

<?php
$html_code = "<html><body><h1>Hello, World!</h1></body></html>";
highlight_string($html_code);
?>