How many ways I can redirect a PHP page? ~ Interview Questions & Answers

Friday, June 5, 2009

How many ways I can redirect a PHP page?

a. Header function in PHP redirects to a new URL
Example:
<?php
header("Location: http://www.redirecturl.com/");
?>
b. http_redirect() is also used to redirect to a new page or URL.
Syntax
void http_redirect ( [string url [, array params [, bool session = FALSE [, int status]]]] )
Here, the URL is the path of the new page. params can be some query parameters followed by whether the session information needs to be passed and the custom response status code.

0 comments: