How can PHP developers ensure that header redirection occurs immediately after script execution, without waiting for completion?

To ensure that header redirection occurs immediately after script execution in PHP, developers can use the `exit()` function after sending the header. This will stop the script execution and redirect the user to the specified location without waiting for the rest of the script to finish.

<?php
header("Location: https://www.example.com");
exit();
?>