What worked for me was to use the PHP HEREDOC syntax to stuff the html into a PHP string --
<pre> <?php $str=<<<HEREDOC html code including most anything (but not more php) HEREDOC; echo htmlentities($str); ?> </pre>