search
Homephp教程php手册Summary of commonly used header header definitions in PHP

? php header ('HTTP/1.1 200 OK'); // ok normal access header ('HTTP/1.1 404 Not Found'); // notify the browser that the page does not exist header ('HTTP/1.1 301 Moved Permanently '); // Set the address to be permanently redirected 301 header ('Location: http://www.ithhc.cn/'); // Jump to a

<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>


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)