What is the significance of the "Location" header function in PHP and how does it affect the flow of the application?

The "Location" header function in PHP is used to redirect the user to a different page or URL. This can be helpful for scenarios like after form submissions or when a user needs to be redirected to a different page based on certain conditions. It affects the flow of the application by immediately redirecting the user to the specified location.

<?php
// Redirect to a different page after form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Process form data
    
    // Redirect to thank you page
    header("Location: thank-you.php");
    exit();
}
?>