<?php
1. Header (String,[replace,[http_response_code]]): function sends the original HTTP header to the client
String: A message string with two special message requests, the first of which begins with "htpp/" and will be used to calculate the HTTP status code to be sent.
The second is the header information for "location". It not only sends the warmth to the browser, but also gives the browser a redirect (302) status code, unless previously set to 201 or 3xx
Replace: Parameter optional parameter that indicates whether the previous similar message information should be replaced with the same type of insulation information as the following. By default, a substitution occurs. But
If you pass in a false, then you can force the same insulation information to coexist
Http_response_code: Force specifies the value of the HTTP response, which is valid only if the string is not empty
HTTP messages
HTTP consists of three parts: request line, request header, and request body.
HTTP message detailed explanation, website: http://blog.csdn.net/zhll3377/article/details/7748086
Common HTTP Request message header properties
The Accept Request message tells the client what type of response to accept via an "accept" message header property
The value of the Accept property can be one or more MIME-type values, about MIME type reference: Http://baike.baidu.com/link?url=FebRdBqeTBHbEJThQd9c3xWX_ Pw8uzj1js54m4l0iulpl6iccnc41khjmicroqro
MIME (Multipurpose Internet Mail extention): The multi-use Internet Mail Extension type is the type of file that is set up with an extension that is opened by an application,
When the extension file is accessed, the browser automatically opens with the specified program, and is used to specify some client-defined file names and how to open some media files
Commonly used MIME types:
Hypertext Markup Language:. HTML text/html;
XML document:. XML text/xml;
XHTML documentation: XML Application/xhtml+xml;
Plain text:. txt text/plain;
RTF text:. rtf application/rtf;
PDF text:. pdf application/pdf;
Miscrosoft Word file. Word Application/msword;
PNG images. png image/png;
GIF graphics. gif image/gif;
JPEG graphics. Jpeg.jpg image/jpeg;
Au sound file. au audio/basic;
MIDI music files. Mid.midi Audio/midi,audio/x-midi;
RealAudio music files. Ra,.ram Audio/x-pn-realaudio;
MPEG files. Mpg.mpeg video/mpeg;
AVI file. avi Video/x-msvideo;
gzip file. GZ application/x-gzip;
Tar file. Tar Application/x-tar;
Any binary data application/octet-stream;
Cookie: The client's cookie is passed to the server via this message header property.
There's a sessionid or something, and the server is using this to make sure that multiple requests belong to the same session.
Referer: Which URL to represent this request, if you search for a business through Google Ads page, you are interested in this ad page, the mouse to send a request message to the Merchant website, the request message of the Referer Message header attribute is http:// www.google.com;
A lot of seemingly magical web monitoring software (such as the famous I Want), as long as you put a piece of JavaScript on your Web page, you can monitor traffic, the country's distribution of customer access reports and charts, the principle is through this referer and some other HTTP headers work.
Cache-control: Controls the buffering if a request wants to respond to the returned content
The client is buffered for one year, or does not want to be buffered to achieve the purpose through this header.
eg. forcing the browser to not buffer
Header (' expires:mon,26 Jul 1997 05:00:00 GMT ');
Header (' Cacthe-control:no-cache ');
Header (' Pragma:no-cache ');
Download file
Header (' content-type:appalication/pdf ');
Files are called Downloaded.pdf
Header (' content-disposition:attachment;filename=downloaded.pdf ');
PDF Source in Original.pdf
ReadFile (' original.pdf ');
2.headers_list (): function returns a list of sent (or pending response headers)
The function returns an array containing the header
eg
Setcookie ("TestCookie", "somevalue");
Header ("X-sample-test:foo");
Header (' Content-type:text/plain ');
Echo '
Var_dump (Headers_list ());
Echo ' </body>
3.headers_sent (): function checks if the HTPP header is sent, where it was sent
Returns true if the header has been sent, otherwise false
?>
This article is from "Tiger Brother's Blog" blog, please be sure to keep this source http://7613577.blog.51cto.com/7603577/1560166
Summary of PHP header functions