Summary of common PHP header definitions and phpheader Headers

Source: Internet
Author: User

Summary of common PHP header definitions and phpheader Headers

The header () function sends the original HTTP header to the client.

It is important to realize that the header () function must be called before any actual output is sent (in PHP 4 and later versions, you can use the output cache to solve this problem):

<? Phpheader ('HTTP/1.1 200 OK '); // OK normal access header ('HTTP/1.1 404 Not Found '); // notify the browser that the page does not contain the header ('HTTP/1.1 301 Moved Permanently '); // set the address to be Permanently redirected to the 301 header ('location: http://www.ithhc.cn /'); // jump to a new address header ('refresh: 10; url = http://www.ithhc.cn/'); // The delayed redirection is the jump header ('x-Powered-: PHP/6.0.0 '); // modify the X-Powered-By header ('content-language: en'); // the header of the Document language ('content-Length: 1234 '); // set the Content Length header ('Last-Modified :'. gmdate ('d, d m y h: I: s', $ time ). 'gmt'); // tell the browser the last modification time header ('HTTP/1.1 304 Not modified '); // tell the browser that the document Content has not changed ### Content Type ### header ('content-Type: text/html; charset = UTF-8 '); // webpage encoding header ('content-Type: text/plain '); // plain text format header ('content-Type: image/jpeg '); // JPG and JPEG headers ('content-Type: application/zip'); // zip file header ('content-Type: application/pdf '); // PDF File header ('content- Type: audio/mpeg '); // audio file header ('content-type: text/css'); // css File header ('content-type: text/javascript '); // js File header ('content-type: application/json'); // jsonheader ('content-type: application/pdf '); // Response Header ('content-type: text/xml'); // xmlheader ('content-Type: application/x-shockw ** e-flash '); // Flash Animation ######### declare a downloaded file ### header ('content-Type: application/octet-stream'); header ('content -Disposition: attachment; filename = "ITblog.zip" '); header ('content-Transfer-Encoding: binary'character Encoding readfile('test.zip '); ######## disable caching for the current document ### header ('cache-Control: no-Cache, no-store, max-age = 0, must-revalidate '); header ('expires: Mon, 26 Jul 1997 05:00:00 gmt '); ######## display a Login Dialog box to be verified ### header ('HTTP/1.1 401 unauthorized'); header ('www-Authenticate: basic realm = "Top Secret" '); ######## declare an xls file to be downloaded Parts ### header ('content-Disposition: attachment; filenameithhc.xlsx'); header ('content-Type: application/vnd. openxmlformats-officedocument.spreadsheetml.sheet '); header ('content-Length :'. filesize ('. /test.xls '); header ('content-Transfer-Encoding: binary'); header ('cache-Control: must-revalidate '); header ('pragma: public '); readfile ('. /test.xls '); ######?>

The above is all the content of this article. I hope you will like it.

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.