Introduction to PHP Redirects
Using the header
function, you can
redirect the browser from one page
to another. To do this, you need to pass
the HTTP Location header in it:
<?php
header('Location: test.php');
?>
The target page address can also be stored in a variable:
<?php
$addr = 'test.php';
header('Location: ' . $addr);
?>
Instead of concatenation, you can use variable interpolation:
<?php
$addr = 'test.php';
header("Location: $addr");
?>
When visiting the page index.php
,
perform a redirect to the page
page.php
.