Summary of definitions of common PHP header and phpheader header _ PHP Tutorial

Source: Internet
Author: User
A summary of common PHP header definitions and a summary of phpheader headers. The PHP header definition is summarized, and the phpheader header summary header () function sends the original HTTP header to the client. It is important to realize that the actual output must be summarized by the header definitions commonly used by PHP, and the phpheader header must be summarized.

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 header ('x-Powered-By: PHP/6.0.0 '); // modify the X-Powered-By header ('content-language: en'); // The header of the document language ('content-Length: 6666 '); // 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 heade R ('content-Type: image/jpeg '); // JPG, JPEG header ('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'includedreadfile('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 0 5:00:00 GMT'); ######## display a login confirmation dialog box ### header ('http/1.1 401 unauthorized '); header ('www-Authenticate: Basic realm = "Top Secret "'); ######## declare an xls file to be downloaded ### header ('content-Disposition: attachment; filename=ithhc.xlsx'); header ('content-Type: application/vnd. openxmlformats-officedocument.spreadsheetml.sheet '); header ('content-Length :'. filesize ('. /test.xls '); header ('content-Transfer-Encoding: B Inary '); 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.

The common header definition summary for http://www.bkjia.com/PHPjc/1019457.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1019457.htmlTechArticlePHP, the phpheader header summary header () function sends the original HTTP header to the client. It is important to realize that, in any actual output...

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.