What best practices should be followed when integrating PHP code into HTML files?

When integrating PHP code into HTML files, it is important to follow best practices to ensure clean and maintainable code. One common approach is to separate PHP logic from HTML markup by using PHP opening and closing tags within the HTML file. This helps to keep the code organized and makes it easier to identify and modify PHP code within the HTML file.

<!DOCTYPE html>
<html>
<head>
    <title>PHP Integration</title>
</head>
<body>
    <h1>Welcome <?php echo "John Doe"; ?></h1>
    <?php
    $message = "Hello, World!";
    echo "<p>$message</p>";
    ?>
</body>
</html>