header
(PHP 3, PHP 4 )
header -- Send a raw HTTP header
Description
void header ( string string [, bool replace [, int http_response_code]])
header() is used to send raw HTTP headers. See the HTTP/1.1
specification for more information on HTTP headers.
The optional replace parameter indicates whether the header
should replace a previous similar header, or add a second
header of the same type. By default it will replace, but
if you pass in FALSE as the second argument you can force
multiple headers of the same type. For example:
<?php
header('WWW-Authenticate: Negotiate');
header('WWW-Authenticate: NTLM', false);
?>
The second optional http_response_code force the HTTP response
code to the specified value. (This parameter is available
in PHP 4.3.0 and higher.)
There are two special-case header calls. The first is a
header that starts with the string "HTTP/" (case
is not significant), which will be used to figure out the
HTTP status code to send. For example, if you have configured
Apache to use a PHP script to handle requests for missing
files (using the ErrorDocument directive), you may want
to make sure that your script generates the proper status
code.
<?php
header("HTTP/1.0 404 Not Found");
?>
Note: The HTTP status header line will always be the first
sent to the client, regardless of the actual header() call
being the first or not. The status may be overridden by
calling header() with a new status line at any time unless
the HTTP headers have already been sent.
|