How can PHP be used to redirect URLs without changing the displayed link?

To redirect URLs without changing the displayed link in PHP, you can use the header() function to send a raw HTTP header to perform the redirection. This method allows you to redirect users to a different page while keeping the original URL displayed in the browser.

<?php
// Set the URL to redirect to
$redirect_url = 'https://www.example.com/newpage';

// Send a raw HTTP header to perform the redirection
header('Location: ' . $redirect_url);
exit;
?>