Redirection in PHP

PHPServer Side ProgrammingProgramming

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: http://www.tutorialspoint.com");
   exit;
?>

The website to which the page needs to be redirected is specified in the header function.

raja
Published on 01-Jul-2020 10:49:29
Advertisements