How can the header() function in PHP be utilized to redirect users to a new URL?

To redirect users to a new URL in PHP, you can use the header() function with the 'Location' parameter set to the desired URL. This function sends a raw HTTP header to the browser, which then redirects the user to the specified location. Make sure to call the header() function before any output is sent to the browser to avoid any errors.

<?php
// Redirect to a new URL
header("Location: http://www.example.com");
exit; // Make sure to stop the script execution after the redirect
?>