How can PHP be separated from HTML to improve code readability and maintainability?

To separate PHP from HTML for better code readability and maintainability, one can use PHP's alternative syntax for control structures like if, foreach, and while loops. This helps to clearly distinguish between PHP logic and HTML presentation in the code.

<?php
// PHP logic separated from HTML
$items = ['Apple', 'Banana', 'Orange'];

foreach ($items as $item):
?>
    <p><?php echo $item; ?></p>
<?php
endforeach;
?>