The header function in PHP can be used to redirect the user from one page to another. It is an in-built function that sends raw HTTP header to the destination (client).
Syntax of header function
header( $header_value, $replace_value, $http_response_code)
Following are the parameters −
- The ‘header_value’ in the function is used to store the header string.
- The ‘replace_value’ parameter stores the value that needs to be replaced.
- The ‘response_code’ is used to store the HTTP response code.
Example
<?php header("Location: https://www.tutorialspoint.com"); exit; ?>
The website to which the page needs to be redirected is specified in the header function.