What best practices should be followed when including PHP code in a website to avoid errors or display issues?

When including PHP code in a website, it is important to follow best practices to avoid errors or display issues. One common issue is mixing PHP and HTML code without proper syntax or structure, which can lead to parsing errors or unexpected output. To solve this, it is recommended to use PHP opening and closing tags correctly within the HTML code to ensure proper execution and output.

<?php
// Correct way to include PHP code in HTML
?>
<!DOCTYPE html>
<html>
<head>
    <title>Example Page</title>
</head>
<body>
    <h1>Welcome to our website!</h1>
    <?php
    // PHP code here
    ?>
</body>
</html>