Home Backend Development PHP Tutorial PHP 惯用的header头部定义汇总

PHP 惯用的header头部定义汇总

Jun 13, 2016 pm 12:28 PM
application content header http type

PHP 常用的header头部定义汇总

1

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

Copy after login

 

Statement of this Website
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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does http status code 520 mean? What does http status code 520 mean? Oct 13, 2023 pm 03:11 PM

HTTP status code 520 means that the server encountered an unknown error while processing the request and cannot provide more specific information. Used to indicate that an unknown error occurred when the server was processing the request, which may be caused by server configuration problems, network problems, or other unknown reasons. This is usually caused by server configuration issues, network issues, server overload, or coding errors. If you encounter a status code 520 error, it is best to contact the website administrator or technical support team for more information and assistance.

What is http status code 403? What is http status code 403? Oct 07, 2023 pm 02:04 PM

HTTP status code 403 means that the server rejected the client's request. The solution to http status code 403 is: 1. Check the authentication credentials. If the server requires authentication, ensure that the correct credentials are provided; 2. Check the IP address restrictions. If the server has restricted the IP address, ensure that the client's IP address is restricted. Whitelisted or not blacklisted; 3. Check the file permission settings. If the 403 status code is related to the permission settings of the file or directory, ensure that the client has sufficient permissions to access these files or directories, etc.

What does linux header mean? What does linux header mean? Jul 18, 2023 pm 03:34 PM

The Linux header refers to the beginning of a file or data stream, which is used to contain metadata about the content. By correctly writing and using Header files, developers can better utilize system resources and improve code readability and Maintainability.

How to use Nginx Proxy Manager to implement automatic jump from HTTP to HTTPS How to use Nginx Proxy Manager to implement automatic jump from HTTP to HTTPS Sep 26, 2023 am 11:19 AM

How to use NginxProxyManager to implement automatic jump from HTTP to HTTPS. With the development of the Internet, more and more websites are beginning to use the HTTPS protocol to encrypt data transmission to improve data security and user privacy protection. Since the HTTPS protocol requires the support of an SSL certificate, certain technical support is required when deploying the HTTPS protocol. Nginx is a powerful and commonly used HTTP server and reverse proxy server, and NginxProxy

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

What are the uses of the Type keyword in Go? What are the uses of the Type keyword in Go? Sep 06, 2023 am 09:58 AM

The usage of the Type keyword in Go includes defining new type aliases or creating new structure types. Detailed introduction: 1. Type alias. Use the "type" keyword to create an alias for an existing type. This alias does not create a new type, but only provides a new name for the existing type. Type aliases can improve code. The readability of the code makes the code clearer; 2. Structure type. Use the "type" keyword to create a new structure type. The structure is a composite type that can be used to define custom types containing multiple fields. etc.

Solve Ubuntu mounting mobile hard disk error: unknown file system type exfat Solve Ubuntu mounting mobile hard disk error: unknown file system type exfat Jan 05, 2024 pm 01:18 PM

An error occurs when ubuntu mounts a mobile hard disk: mount: unknownfilesystemtype'exfat'. The processing method is as follows: Ubuntu13.10 or install exfat-fuse: sudoapt-getinstallexfat-fuseUbuntu13.04 or below sudoapt-add-repositoryppa:relan/exfatsudoapt-getupdatesudoapt-getinstallfuse- exfatCentOS Linux mount exfat format USB disk error solution to load extfa in CentOS

Send POST request with form data using http.PostForm function Send POST request with form data using http.PostForm function Jul 25, 2023 pm 10:51 PM

Use the http.PostForm function to send a POST request with form data. In the http package of the Go language, you can use the http.PostForm function to send a POST request with form data. The prototype of the http.PostForm function is as follows: funcPostForm(urlstring,dataurl.Values)(resp*http.Response,errerror)where, u

See all articles