What are the potential risks of having HTML tags within a for loop in PHP?

Having HTML tags within a for loop in PHP can lead to messy and hard-to-read code. It can also make it difficult to maintain and update the code in the future. To solve this issue, you can separate the HTML markup from the PHP logic by using alternative syntax like heredoc or concatenating strings.

<?php
// Example of using heredoc syntax to separate HTML from PHP logic
for ($i = 0; $i < 5; $i++) {
    $output = <<<HTML
    <div class="item">
        <p>Item $i</p>
    </div>
HTML;
    echo $output;
}
?>