What potential issues can arise when mixing HTML and PHP code in the same file?

Potential issues that can arise when mixing HTML and PHP code in the same file include readability issues, maintainability problems, and potential security vulnerabilities if not properly sanitized. To solve these issues, it's recommended to separate the PHP logic from the HTML markup by using PHP's control structures like loops and conditionals to generate the HTML dynamically.

<?php
// Example of separating PHP logic from HTML markup
$items = ['Apple', 'Banana', 'Orange'];

foreach ($items as $item) {
    echo '<li>' . $item . '</li>';
}
?>