Web EndMemo


PHP Header URL Example


header() function sends a raw HTTP header. header() must be called before any output of the web page. To other words, header() must be used before the <html> tag.

header() is usually used for redirect a web page, for example:
<?PHP
header("LOCATION: index.php");
?>
It will redirect to the "index.php" page.

To use variables in the redirections:
<?PHP
$url="index.php";	
header("LOCATION: http://www.endmemo.com/$url");
?>

If you have "&" and variables in the redirection, the variables should be concatenated with the url string to avoid confusion:
<?PHP
$p1="a";
$p2="b";
header('LOCATION: xxx.php?p1=".$p1."&p2=".$p2');
?>