How can the use of absolute URLs in the "location" header prevent potential errors in PHP scripts?
Using absolute URLs in the "location" header can prevent potential errors in PHP scripts by ensuring that the redirect is always pointing to the correct location regardless of the current working directory or server configuration. This helps avoid issues such as redirect loops or incorrect redirections.
<?php
// Using absolute URL in the "location" header to prevent potential errors
$redirect_url = 'https://example.com/new_page.php';
header('Location: ' . $redirect_url);
exit;
?>