PHP 常用的header头部定义汇总
<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>

The article explains how to create, implement, and use interfaces in PHP, focusing on their benefits for code organization and maintainability.

The article discusses the differences between crypt() and password_hash() in PHP for password hashing, focusing on their implementation, security, and suitability for modern web applications.

Article discusses preventing Cross-Site Scripting (XSS) in PHP through input validation, output encoding, and using tools like OWASP ESAPI and HTML Purifier.

Autoloading in PHP automatically loads class files when needed, improving performance by reducing memory use and enhancing code organization. Best practices include using PSR-4 and organizing code effectively.

PHP streams unify handling of resources like files, network sockets, and compression formats via a consistent API, abstracting complexity and enhancing code flexibility and efficiency.

The article discusses managing file upload sizes in PHP, focusing on the default limit of 2MB and how to increase it by modifying php.ini settings.

The article discusses nullable types in PHP, introduced in PHP 7.1, allowing variables or parameters to be either a specified type or null. It highlights benefits like improved readability, type safety, and explicit intent, and explains how to declar

The article discusses the differences between unset() and unlink() functions in programming, focusing on their purposes and use cases. Unset() removes variables from memory, while unlink() deletes files from the filesystem. Both are crucial for effec


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
