|
Part:
1
2
3
4
5
6
7
(Continued from previous part...)
2. Response header lines: Information about the response:
Accept-Ranges
Age
ETag
Location
Proxy-Authenticate
Retry-After
Server
Vary
WWW-Authenticate
3. Entity header lines: Information about the data requested by the client:
Allow
Content-Encoding
Content-Language
Content-Length
Content-Location
Content-MD5
Content-Range
Content-Type
Expires
Last-Modified
Controlling Header Lines
When a PHP page is requested, the response header lines will be created by the
PHP engine. But you can control all header lines with the header() function. Here
are rules and syntax of the header() function:
1. The syntax of header() is:
void header(string header_line[, bool replace[, int http_response_code]])
2. "header_line" specifies a complete header line string like "Content-Type: text/html".
3. "replace" can be used to replace a previously defined header line of the same identifier.
Default is replacing.
4. "header_line" can be used to set the HTTP response status line like "HTTP/1.1 200 OK".
5. header() must be called before any output to the entity body, if the output buffering is turned off.
6. If header() is called to set "Location" header line, the status line will be set to "HTTP/1.0 302".
7. When header() is called multiple times, the status line will be always outputted first. Other header
lines will be outputted in same order as their calling statements.
Viewing Header Lines
When the client program receives the HTTP response, it will look at the header lines
first. Based on the information contained in the header lines, the client program will
decide what to do with the actual response data in the entity body.
If you use a Web browser as a HTTP client program, it will process the data
in the entity body differently depending on mainly the "Content-Type" entity header line:
displaying the data as it is,
rendering the data as a HTML document and displaying the resulting information,
or passing the data to other registered programs to handle it.
(Continued on next part...)
Part:
1
2
3
4
5
6
7
|