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

PHP常用的header头部定义汇总

WBOY
풀어 주다: 2016-07-06 13:30:44
원래의
1109명이 탐색했습니다.

? 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>
로그인 후 복사

 


관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿