Maison >php教程 >php手册 >PHP常用的header头部定义汇总

PHP常用的header头部定义汇总

WBOY
WBOYoriginal
2016-07-06 13:30:441110parcourir

? php header ('HTTP/1.1 200 OK'); // ok 正常访问 header ('HTTP/1.1 404 Not Found'); // 通知浏览器 页面不存在 header ('HTTP/1.1 301 Moved Permanently'); // 设置地址被永久的重定向 301 header ('Location: http://www.ithhc.cn/'); // 跳转到一个

<span style="color: #000000;">php
</span><span style="color: #008080;">header</span>('HTTP/1.1 200 OK'); <span style="color: #008000;">//</span><span style="color: #008000;"> ok 正常访问</span>
<span style="color: #008080;">header</span>('HTTP/1.1 404 Not Found'); <span style="color: #008000;">//</span><span style="color: #008000;">通知浏览器 页面不存在</span>
<span style="color: #008080;">header</span>('HTTP/1.1 301 Moved Permanently'); <span style="color: #008000;">//</span><span style="color: #008000;">设置地址被永久的重定向 301</span>
<span style="color: #008080;">header</span>('Location: http://www.ithhc.cn/'); <span style="color: #008000;">//</span><span style="color: #008000;">跳转到一个新的地址</span>
<span style="color: #008080;">header</span>('Refresh: 10; url=http://www.ithhc.cn/'); <span style="color: #008000;">//</span><span style="color: #008000;">延迟转向 也就是隔几秒跳转</span>
<span style="color: #008080;">header</span>('X-Powered-By: PHP/6.0.0'); <span style="color: #008000;">//</span><span style="color: #008000;">修改 X-Powered-By信息</span>
<span style="color: #008080;">header</span>('Content-language: en'); <span style="color: #008000;">//</span><span style="color: #008000;">文档语言</span>
<span style="color: #008080;">header</span>('Content-Length: 1234'); <span style="color: #008000;">//</span><span style="color: #008000;">设置内容长度</span>
<span style="color: #008080;">header</span>('Last-Modified: '.<span style="color: #008080;">gmdate</span>('D, d M Y H:i:s', <span style="color: #800080;">$time</span>).' GMT'); <span style="color: #008000;">//</span><span style="color: #008000;">告诉浏览器最后一次修改时间</span>
<span style="color: #008080;">header</span>('HTTP/1.1 304 Not Modified'); <span style="color: #008000;">//</span><span style="color: #008000;">告诉浏览器文档内容没有发生改变  ###内容类型###</span>
<span style="color: #008080;">header</span>('Content-Type: text/html; charset=utf-8'); <span style="color: #008000;">//</span><span style="color: #008000;">网页编码</span>
<span style="color: #008080;">header</span>('Content-Type: text/plain'); <span style="color: #008000;">//</span><span style="color: #008000;">纯文本格式</span>
<span style="color: #008080;">header</span>('Content-Type: image/jpeg'); <span style="color: #008000;">//</span><span style="color: #008000;">JPG、JPEG </span>
<span style="color: #008080;">header</span>('Content-Type: application/zip'); <span style="color: #008000;">//</span><span style="color: #008000;"> ZIP文件</span>
<span style="color: #008080;">header</span>('Content-Type: application/pdf'); <span style="color: #008000;">//</span><span style="color: #008000;"> PDF文件</span>
<span style="color: #008080;">header</span>('Content-Type: audio/mpeg'); <span style="color: #008000;">//</span><span style="color: #008000;"> 音频文件 </span>
<span style="color: #008080;">header</span>('Content-type: text/CSS'); <span style="color: #008000;">//</span><span style="color: #008000;">css文件</span>
<span style="color: #008080;">header</span>('Content-type: text/javascript'); <span style="color: #008000;">//</span><span style="color: #008000;">js文件</span>
<span style="color: #008080;">header</span>('Content-type: application/json'); <span style="color: #008000;">//</span><span style="color: #008000;">json</span>
<span style="color: #008080;">header</span>('Content-type: application/pdf'); <span style="color: #008000;">//</span><span style="color: #008000;">pdf</span>
<span style="color: #008080;">header</span>('Content-type: text/xml'); <span style="color: #008000;">//</span><span style="color: #008000;">xml</span>
<span style="color: #008080;">header</span>('Content-Type: application/x-shockw**e-Flash'); <span style="color: #008000;">//</span><span style="color: #008000;">Flash动画  ######  ###声明一个下载的文件###</span>
<span style="color: #008080;">header</span>('Content-Type: application/octet-stream'<span style="color: #000000;">);
</span><span style="color: #008080;">header</span>('Content-Disposition: attachment; filename="ITblog.zip"'<span style="color: #000000;">);
</span><span style="color: #008080;">header</span>('Content-Transfer-Encoding: binary');<span style="color: #008080;">readfile</span>('test.zip');<span style="color: #008000;">#</span><span style="color: #008000;">#####  ###对当前文档禁用缓存###</span>
<span style="color: #008080;">header</span>('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'<span style="color: #000000;">);
</span><span style="color: #008080;">header</span>('Expires: Mon, 26 Jul 1997 05:00:00 GMT');<span style="color: #008000;">#</span><span style="color: #008000;">#####  ###显示一个需要验证的登陆对话框### </span>
<span style="color: #008080;">header</span>('HTTP/1.1 401 Unauthorized'<span style="color: #000000;">); 
</span><span style="color: #008080;">header</span>('WWW-Authenticate: Basic realm="Top Secret"'); <span style="color: #008000;">#</span><span style="color: #008000;">#####    ###声明一个需要下载的xls文件###</span>
<span style="color: #008080;">header</span>('Content-Disposition: attachment; filename=ithhc.xlsx'<span style="color: #000000;">);
</span><span style="color: #008080;">header</span>('Content-Type: application/vnd.openxmlformats-officedocument.sPReadsheetml.sheet'<span style="color: #000000;">);
</span><span style="color: #008080;">header</span>('Content-Length: '.<span style="color: #008080;">filesize</span>('./test.xls'<span style="color: #000000;">)); 
</span><span style="color: #008080;">header</span>('Content-Transfer-Encoding: binary'<span style="color: #000000;">); 
</span><span style="color: #008080;">header</span>('Cache-Control: must-revalidate'<span style="color: #000000;">); 
</span><span style="color: #008080;">header</span>('Pragma: public'); <span style="color: #008080;">readfile</span>('./test.xls'); <span style="color: #008000;">#</span><span style="color: #008000;">#####?> </span>

 


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn