Wednesday, February 13, 2013

Header function in php

The header() function sends a raw HTTP header to a client.Means Header function is used to redirect one page to another page.header() must be called before any actual output is sent,either by normal HTML tags,blank lines in a file, or from PHP.

Header function Syntax  :
header(string,replace,http_response_code) 

Parameter Description
string Required. Specifies the header string to send
replace Optional. Indicates whether the header should replace previous or add a second header. Default is TRUE (will replace). FALSE (allows multiple headers of the same type)
http_response_code Optional. Forces the HTTP response code to the specified value (available in PHP 4.3 and higher)



Example :
<?php
// This results in an error.
// The output above is before the header() call
header('Location: http://www.example.com/');
?>

No comments:

Post a Comment

Thanks....