Function in PHP

Header Function in PHP

The PHP header() function send the raw HTTP headers request to the browser. In PHP you can used the header function for redirect the user to another location. The Header code must be place at the very top of the page to prevent any other part of the page from loading. The redirect location is specified by the Location attribute. After the Header function exit() function must be be used to stop further processing on the rest of the code.
Syntax:
header('Location: url);

For Example :


header("Location: http://www.learninghints.com/index.php");                /* Redirect browser */

exit;  /* Make sure that code below does not get executed when we redirect. */

?>

You can also pass the some value through the header function
header("location:url?variable=value);
for example
header("location:test.php?id=101");
Note:- if you are passing the long text then must use urlencode() , perhaps in combination with htmlentities(), these two function will be discussed other Tutorials.