|
headerSend a raw HTTP header Description
void header(string
$header , bool $replace = true , int $response_code = 0)header is used to send a raw HTTP header. See the » HTTP/1.1 specification for more information on HTTP headers. Remember that header must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header is called. The same problem exists when using a single PHP/HTML file.
Parameters
Return ValuesNo value is returned. Errors/Exceptions
On failure to schedule the header to be sent, header
issues an Examples
Example #1 Download dialog If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the » Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.
Example #2 Caching directives PHP scripts often generate dynamic content that must not be cached by the client browser or any proxy caches between the server and the client browser. Many proxies and clients can be forced to disable caching with:
Example #3 Setting a cookie setcookie provides a convenient way to set cookies. To set a cookie that includes attributes which setcookie doesn't support, header can be used.
For example, the following sets a cookie that includes a
Notes
See Also
|