What is the best way to handle URL forwarding in PHP?

When handling URL forwarding in PHP, the best way is to use the header() function to send a raw HTTP header to perform the redirection. This function sends a raw HTTP header to the browser, instructing it to redirect to a different location specified in the header. It is important to use this method for URL forwarding to ensure proper redirection without any issues.

<?php
// Redirect to a new URL
$newURL = 'https://www.example.com/newpage.php';
header('Location: ' . $newURL);
exit();
?>