PHP Common Header Head definition rollup

Source: Internet
Author: User
Tags header json readfile zip

This article mainly gives you a summary of PHP commonly used header head definition, very comprehensive and meticulous, the need for small partners can refer to.

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

It is important to recognize that the header () function must be invoked before any actual output is sent (in PHP 4 and later, you can use output caching to solve the problem):

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55-56 <?php header (' http/1.1 OK '); OK normal access header (' http/1.1 404 Not Found '); Notifies the browser that the header page does not exist (' http/1.1 moved Permanently '); The set address is permanently redirected to the header (' location:http://www.ithhc.cn/'); Jump to a new address header (' refresh:10; url=http://www.ithhc.cn/'); Delay steering is the jump header (' x-powered-by:php/6.0.0 ') every few seconds; Modify x-powered-by Information header (' Content-language:en '); Document Language header (' content-length:1234 '); Set the content Length header (' last-modified: '. Gmdate (' d, D M Y h:i:s ', $time). ' GMT '); Tells the browser the last time the header was modified (' http/1.1 304 not Modified '); Tell the browser that the contents of the document have not changed   # # #内容类型 ### header (' content-type:text/html charset=utf-8 '); Web page encoding header (' Content-type:text/plain '); Plain Text Format header (' 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 '); JSON headER (' content-type:application/pdf '); PDF header (' Content-type:text/xml '); XML header (' Content-type:application/x-shockw**e-flash '); Flash animation   ######   # # #声明一个下载的文件 ### header (' Content-type:application/octet-stream '); Header (' content-disposition:attachment; filename= "Itblog.zip"); Header (' content-transfer-encoding:binary '); ReadFile (' Test.zip '); ######   # # #对当前文档禁用缓存 ### header (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate '); Header (' Expires:mon, June 1997 05:00:00 GMT '); ######   # # #显示一个需要验证的登陆对话框 ### header (' http/1.1 401 Unauthorized '); Header (' Www-authenticate:basic realm= "top Secret"); ######     # # #声明一个需要下载的xls文件 ### 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:binary '); Header (' cache-control:must-revalidate '); Header (' Pragma:puBlic '); ReadFile ('./test.xls '); ######?>

The above is the entire contents of this article, I hope you can enjoy.

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.