In what situations should HTML tags be omitted from PHP scripts, especially when a redirect is intended?

When a redirect is intended in a PHP script, HTML tags should be omitted to prevent any output before the redirect header is sent. This is because header functions in PHP must be sent before any output is generated. To ensure a successful redirect, make sure to omit any HTML tags, whitespace, or other content before calling the header function for the redirect.

<?php
// Omit HTML tags to ensure successful redirect
header("Location: newpage.php");
exit;
?>