What are the potential pitfalls of placing PHP code outside of the <html> tags in a web page?

Placing PHP code outside of the <html> tags in a web page can cause syntax errors or unexpected output to be displayed on the page. To avoid this issue, all PHP code should be enclosed within <?php ?> tags and placed within the <html> tags.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;My Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;?php
        // PHP code here
        echo &quot;Hello, World!&quot;;
    ?&gt;
&lt;/body&gt;
&lt;/html&gt;