The function of the header () function in PHP is to send header information to the client.
What is header information?
Here is a simple explanation, detailed self-view HTTP protocol.
In the HTTP protocol, the server side of the answer (response) content includes two parts: header information (headers) and body content, where the header information is not the What is the use of the header information?
The function of the head information is many, the main one has the following several:
1, Jump: When the browser to accept the header information in the Location:xxxx, will automatically jump to xxxx point to the URL address, this is a bit like with JS write jump. But this jump only browser know, regardless of the contents of the content, the user can not see.
2, specify the content of the Web page: the same XML file, if the header information is specified: Content-type:application/xml, the browser will be in accordance with the XML file format parsing. However, if the header message is: Content-type:text/xml, the browser will treat it as a text parsing. (The browser does not parse the file by extension)
Do not know if you have noticed, sometimes in some sites to download things, click to download the connection, the result browser will be the attachment as a Web page opened, the display is garbled, the problem is also related to the header information. Sometimes the browser according to Content-type to determine whether to open or save, so that sometimes you can judge the error (mainly the site designer forgot to write Content-type). In fact, there is another can be to specify the content as an attachment, need to save, this is: content-disposition:attachment; Filename= "xxxxx"
Http://zhidao.baidu.com/link?url=fHbnmwvDP28fSoTpD3s5bnXgA2ndoegXoXXxh5CBNGF7iwrk7f-tejIwE3WU-iyRRultSESINiTmRw6ZFkjE5_
Header function in PHP