PHP header() Function
The header() function sends a raw HTTP header to a client.
It is important to notice that header() must be called before any actual output is sent.
Syntax
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
<!DOCTYPE html> <html> <head> <title>header function</title> </head> <body> <?php // redirect page to google.com header ('Location: http://www.google.com/'); ?> </body> </html>