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");
Keywords
Related Questions
- How can the array_walk_recursive function in PHP be applied to nested arrays and what are its limitations?
- What are some common methods for handling calculations involving decimal numbers in PHP?
- How can PHP be used to filter out users with no entries in a specific column from the results of a query?