How can the HTTP Status Header be managed when using the header() function in PHP for redirection?
When using the `header()` function in PHP for redirection, the HTTP Status Header can be managed by including the appropriate status code along with the location header. This allows you to specify the status code for the redirection response, such as 301 for permanent redirection or 302 for temporary redirection.
// Specify the status code along with the location header for redirection
header("Location: http://example.com/newpage.php", true, 301);
exit();
Related Questions
- How can PHP be used to validate and sanitize user input when uploading files to a server?
- How can PHP developers ensure that cookies are accepted without the need for manual page reloads?
- How can PHP developers ensure that file paths are correctly constructed and passed to functions like fopen for file manipulation tasks?