What are potential pitfalls when mixing PHP and HTML in a script?

Mixing PHP and HTML in a script can lead to readability issues and make the code harder to maintain. To solve this problem, it's recommended to separate PHP logic from HTML markup by using PHP opening and closing tags within the HTML code.

<?php
// PHP logic here

?>

<!DOCTYPE html>
<html>
<head>
    <title>PHP and HTML Example</title>
</head>
<body>
    <h1><?php echo "Hello, World!"; ?></h1>
</body>
</html>