What is the function used to redirect to a different URL in PHP?
To redirect to a different URL in PHP, you can use the header() function with the 'Location' parameter. This function sends a raw HTTP header to the browser, which then redirects the user to the specified URL. It is important to note that the header() function must be called before any actual output is sent to the browser to avoid any errors.
<?php
// Redirect to a different URL
header("Location: https://www.example.com");
exit;
?>