The PHPheader function provides an example of setting an http packet header. _ PHP Tutorial

Source: Internet
Author: User
Tags http cookie
The PHPheader function provides an example of setting an http packet header ,. PHPheader function sets http packet header example details, define the encoding header (Content-Type: texthtml; charsetutf-8); Atomheader (Content-type: applicationatom + xml ); CSSheader (PHP header function setting example of http packet header,
// Define the encoding headers ('content-Type: text/html; charset = utf-8 '); // Atomheader ('content-type: application/atom + XML '); // CSSheader ('content-type: text/css '); // Javascriptheader ('content-type: text/javascript'); // JPEG Imageheader ('content-type: image/jpeg '); // JSONheader ('content-type: application/json'); // response header ('content-type: application/pdf '); // RSSheader ('content-Type: application/rss + xml; charset = ISO-8859-1 '); // Text (Plain) header ('content-type: text/plain '); // XMLheader ('content-type: text/XML'); // 200 OKheader ('http/1.1 200 OK '); // set a 404 header: header ('http/1.1 404 Not Found '); // Set the address to be Permanently redirected header ('http/1.1 301 Moved Permanently '); // go to a new address header ('Location: http://www.example.org/'); // File delay redirection: header ('refresh: 10; url = http://www.example.org /'); print 'You will be redirected in 10 seconds '; // of course, You can also use html syntax to implement //
 

# Appendix: Requests for HTTP header details
Header Explanation Example
Accept Specifies the content type that the client can receive Accept: text/plain, text/html
Accept-Charset String set that the browser can accept. Accept-Charset: ISO-8859-5
Accept-Encoding Specifies the type of content compression encoding that can be returned by the web server supported by the browser. Accept-Encoding: compress, gzip
Accept-Language Acceptable browser language Accept-Language: en, zh
Accept-Ranges You can request one or more sub-range fields of a webpage object. Accept-Ranges: bytes
Authorization HTTP authorization certificate Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ =
Cache-Control Specify the cache mechanism for requests and responses Cache-Control: no-cache
Connection Indicates whether a persistent connection is required. (HTTP 1.1 performs persistent connections by default) Connection: close
Cookie When an HTTP request is sent, all cookie values stored under the domain name of the request are sent to the web server. Cookie: $ Version = 1; Skin = new;
Content-Length Request content length Content-Length: 348
Content-Type MIME Information of the request corresponding to the object Content-Type: application/x-www-form-urlencoded
Date Date and time when the request was sent Date: Tue, 15 Nov 2010 08:12:31 GMT
Secondary CT Specific server behavior of the request Secondary CT: 100-continue
From Email of the user sending the request From: user@email.com
Host Specify the domain name and port number of the requested server Host: www.zcmhi.com
If-Match Valid only when the request content matches the object If-Match: "737060cd8c284d8af7ad3082f209582d"
If-Modified-Since If the request is modified after the specified time, the request is successful. if the request is not modified, code 304 is returned. If-Modified-Since: Sat, 29 Oct 2010 19:43:31 GMT
If-None-Match If the content is not changed, the system returns the 304 code. the parameter is the Etag previously sent by the server. compare it with the Etag responded by the server to determine whether the Etag is changed. If-None-Match: "737060cd8c284d8af7ad3082f209582d"
If-Range If the entity has not changed, the server sends the part lost by the client; otherwise, the whole entity is sent. The parameter is also Etag. If-Range: "737060cd8c284d8af7ad3082f209582d"
If-Unmodified-Since The request is successful only when the object is not modified after the specified time. If-Unmodified-Since: Sat, 29 Oct 2010 19:43:31 GMT
Max-Forwards Restrict the time when information is transmitted through the proxy and Gateway Max-Forwards: 10
Pragma Used to include specific instructions Pragma: no-cache
Proxy-Authorization Connect to the proxy authorization certificate Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ =
Range Request only part of the object, specifying the range Range: bytes = 500-999
Referer The address of the previous webpage, followed by the current requested webpage. Referer: http://www.zcmhi.com/archives/71.html
TE The client is willing to accept the transfer code and notifies the server to accept the tail header information. TE: trailers, deflate; q = 0.5
Upgrade Specify a certain transmission protocol to the server for server conversion (if supported) Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
User-Agent The User-Agent content contains the User information that sends the request. User-Agent: Mozilla/5.0 (Linux; X11)
Via Notify the intermediate gateway or proxy server address, communication protocol Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
Warning Message entity warning information Warn: 199 Miscellaneous warning
Responses section
Header Explanation Example
Accept-Ranges Indicates whether the server supports specified range requests and the type of segmented requests Accept-Ranges: bytes
Age Estimated time from the origin server to the proxy cache (in seconds, non-negative) Age: 12
Allow Valid request behavior for a network resource. if the request is not allowed, 405 is returned. Allow: GET, HEAD
Cache-Control Tell all cache mechanisms whether they can be cached or not Cache-Control: no-cache
Content-Encoding The compression encoding type of the returned content supported by the web server. Content-Encoding: gzip
Content-Language Response body language Content-Language: en, zh
Content-Length Response body length Content-Length: 348
Content-Location Another alternative address that the requested resource can replace Content-Location:/index.htm
Content-MD5 Returns the MD5 checksum of the resource. Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ =
Content-Range Bytes in the whole returned body Content-Range: bytes 21010-47021/47022
Content-Type MIME type of returned content Content-Type: text/html; charset = utf-8
Date Time when the original server message was sent Date: Tue, 15 Nov 2010 08:12:31 GMT
ETag Current value of the object tag of the request variable ETag: "737060cd8c284d8af7ad3082f209582d"
Expires Response expiration date and time Expires: Thu, 01 Dec 2010 16:00:00 GMT
Last-Modified Last modification time of the requested resource Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT
Location Used to redirect the recipient to a location other than the requested URL to complete the request or identify a new resource Location: http://www.zcmhi.com/archives/94.html
Pragma Includes the implementation of specific commands that can be applied to any receiver on the response chain. Pragma: no-cache
Proxy-Authenticate It specifies the authentication scheme and the parameters that can be applied to the URL of the proxy. Proxy-Authenticate: Basic
Refresh Apply to redirection or a new resource is created and redirected in 5 seconds (proposed by Netscape and supported by most browsers)

Refresh: 5; url =

Http://www.zcmhi.com/archives/94.html

Retry-After If the object is temporarily unavailable, notify the client to try again after the specified time Retry-After: 120
Server Web server software name Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
Set-Cookie Set Http Cookie Set-Cookie: UserID = JohnDoe; Max-Age = 3600; Version = 1
Trailer Indicates that the header field exists at the end of the multipart transfer encoding. Trailer: Max-Forwards
Transfer-Encoding File transfer encoding Transfer-Encoding: chunked
Vary Tell the downstream proxy whether to use cache response or request from the original server Vary :*
Via Tell the proxy client where the response is sent Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
Warning Warning possible entity problems Warning: 199 Miscellaneous warning
WWW-Authenticate Indicates the authorization scheme that the client request entity should use WWW-Authenticate: Basic
OriginalHttp://blog.csdn.net/wyqwclsn/article/details/41082083

The http://www.bkjia.com/PHPjc/1102857.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1102857.htmlTechArticlePHP header function sets the http header example details, // defines the encoding header ('content-Type: text/html; charset = utf-8 '); // Atomheader ('content-type: application/atom + XML'); // CSSheader (...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.