How can the use of relative URIs in the header() function impact the redirection in PHP?

When using relative URIs in the header() function for redirection in PHP, the browser may interpret the URI relative to the current URL, leading to unexpected or broken redirects. To ensure proper redirection, it's recommended to use absolute URIs instead.

// Incorrect redirection using relative URI
header("Location: /newpage.php");

// Correct redirection using absolute URI
header("Location: http://example.com/newpage.php");