How can automatic redirection to another website be programmed in PHP?

To automatically redirect users to another website in PHP, you can use the header() function to send a raw HTTP header to the browser. This header should include the "Location" parameter with the URL of the destination website. This will instruct the browser to redirect to the specified URL.

<?php
// Redirect to another website
$redirect_url = 'https://www.example.com';
header('Location: ' . $redirect_url);
exit();
?>