The header () function sends a raw HTTP header to the client. Header (String,replace,http_response_code) It is important to see that the title () must be sent in any so-called actual output
PHP Header Function Tutorial
Definition and usage
The header () function sends a raw HTTP header to the client.
It is important to see that the title () must be sent in any so-called actual output (in PHP 4 and later, you can use output buffering to solve this problem):
This results in an error.
The output above is before the header () call
Header (' location:http://www.example.com/');
?>
Grammar:
Header (String,replace,http_response_code)
Parameter |
Description |
| String |
Required. The specified caption string is sent |
| Replace |
Optional Indicates whether the caption should supersede the previous or add a second caption. The default value is True (supersedes). False (allows multiple headings of the same type) |
| Http_response_code |
Optional Force HTTP response code to the specified value (available in PHP 4.3 and higher) |
Hints and instructions Note: Since PHP 4.4 This feature can prevent more than one header from being sent at a time. This is a protection against head injection attacks. Example 1 prevents page caching:
Date in the Pastheader ("Expires:mon, Jul 1997 05:00:00 GMT"), Header ("Cache-control:no-cache"), Header ("Pragma:no-c Ache ");
Example 2 lets the user prompt to save the generated PDF file (the content disposition header is used to provide the suggested file name and forces the browser to display the Save dialog):
Header ("Content-type:application/pdf");
It'll be called Downloaded.pdfheader ("Content-disposition:attachment;filename= ' downloaded.pdf '");
The PDF source is in Original.pdfreadfile ("original.pdf");
http://www.bkjia.com/PHPjc/445505.html www.bkjia.com true http://www.bkjia.com/PHPjc/445505.html techarticle the header () function sends a raw HTTP header to the client. The header (String,replace,http_response_code) is important to see that the title () must be sent in any so-called actual output ...