What are the common pitfalls in integrating PHP scripts into HTML documents, and how can they be avoided?

One common pitfall in integrating PHP scripts into HTML documents is mixing PHP and HTML code incorrectly, leading to syntax errors. To avoid this, make sure to properly open and close PHP tags within the HTML document. Example fix:

<?php
// Correct way to integrate PHP script into HTML document
?>
<!DOCTYPE html>
<html>
<head>
    <title>PHP Integration</title>
</head>
<body>
    <h1><?php echo "Hello, World!"; ?></h1>
</body>
</html>