php常用的header头
<?php /**
* php常用的header头设置...
*/
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/'); //跳转到一个新的地址
header('Refresh: 10; url=http://www.ithhc.cn/'); //延迟转向 也就是隔几秒跳转
header('X-Powered-By: PHP/6.0.0'); //修改 X-Powered-By信息
header('Content-language: en'); //文档语言
header('Content-Length: 1234'); //设置内容长度
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); //告诉浏览器最后一次修改时间
header('HTTP/1.1 304 Not Modified'); //告诉浏览器文档内容没有发生改变 ###内容类型###
header('Content-Type: text/html; charset=utf-8'); //网页编码
header('Content-Type: text/plain'); //纯文本格式
header('Content-Type: image/jpeg'); //JPG、JPEG
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音频文件
header('Content-type: text/css'); //css文件
header('Content-type: text/javascript'); //js文件
header('Content-type: application/json'); //json
header('Content-type: application/pdf'); //pdf
header('Content-type: text/xml'); //xml
header('Content-Type: application/x-shockw**e-flash'); //Flash动画 ###### ###声明一个下载的文件###
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="ITblog.zip"');
header('Content-Transfer-Encoding: binary');
readfile('test.zip');
###### ###对当前文档禁用缓存###
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
###### ###显示一个需要验证的登陆对话框###
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
###### ###声明一个需要下载的xls文件###
header('Content-Disposition: attachment; filename=ithhc.xlsx');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Length: '.filesize('./test.xls'));
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
readfile('./test.xls');
######
转自:http://www.oschina.net/code/snippet_2246563_46010
php常用的header头的更多相关文章
- Http消息头中常用的请求头和响应头
作为Web开发对常用http的请求头和响应头熟悉了解一下还是很有必要的.比如请求头中Content-type指定了请求的内容,若类型是application/x-www-form-urlencoded ...
- HTTP常用标准请求头字段
常用标准请求头字段 Accept 设置接受的内容类型 Accept: text/plain Accept-Charset 设置接受的字符编码 Accept-Charset: utf-8 Accept- ...
- C++常用的#include头文件总结
C++常用的#include头文件总结 这篇文章主要介绍了C++常用的#include头文件,对初学者理解C++程序设计大有好处的相关资料 本文详细罗列了C++所包含的头文件的名称及作用说明,比较 ...
- php header头信息 举例
发布:sunday01 来源:Net [大 中 小] 转自:http://www.jbxue.com/article/6915.html 用于演示PHP header()函数用法的代码,介 ...
- curl get请求添加header头信息
function get($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CU ...
- postman5.0.2_0+postmanInterceptor0.2.22_0下载安装,可发送header头 cookie 参数
Postman是chrome上一个非常好用的http客户端插件,可惜由于chrome安全的限制,发不出带cookie的请求.如果想要发送带cookie的请求,需要开启Interceptor 安装方法: ...
- header头参数不能带下划线
header头参数不能带下划线:game_id是错误的
- 数据返回正常 而header头Status=500
访问接口数据成功返回,但header头Status Code:500,而调用接口的html用ajax访问一直返回500服务器错误,并且ajax一直走error,走不到success中,错误返回状态是连 ...
- 提取header头进行模块化处理
在进行爬取网上东西的时候一般网站都做了UA的过滤,解决办法就是在代码中加入. 所以才有了本篇提取header头信息单独写成一个模块或者说是函数/类的想法,直接上示例 1.把UA头信息在浏览器中复制出来 ...
随机推荐
- AngularJS 父子控制器
<!doctype html> <html ng-app="myApp"> <head> <script src="C:\\Us ...
- 深入理解Azure自动扩展集VMSS(1)
前文中已经详细介绍了如何配置和部署Azure的虚拟机扩展集VMSS进行自动扩展,但在实际使用过程当中,用户会出现更进一步使用的一些问题,VMSS基本扩展原理及怎么简单调试?如何进行手动扩展?怎么使用自 ...
- Xcode中C、C++、Object-C3种语言的混编
转自: http://hi.baidu.com/onejw/item/f34390c997cdc226a1b50ae http://www.cocoachina.com/ask/questions/s ...
- getResources().getXml()获取xml
获取XML文件的基本思路是,通过getResources().getXml()获的XML原始文件,得到XmlResourceParser对象,通过该对象来判断是文档的开头还是结尾,是某个标签的开始还是 ...
- LeetCode_Subsets
Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be ...
- Android 获取当前日期算前一年、前一月、前一天Calendar
使用Calendar的add(int field, int amount)方法 Calendar ca = Calendar.getInstance();//得到一个Calendar的实例 ca.se ...
- Eclipse + CDT + YAGARTO + J-Link,STM32开源开发环境搭建与调试
Eclipse+CDT+YAGARTO+J-Li:开源开发环境搭建与调试:作者:Chongqing:邮箱:ycq.no1@163.com:文档版本:V1.0:发布日期:2014-08-04:前言:此文 ...
- JS 实现 startWith endWith函数
String.prototype.startWith = function(s) { if (s == null || s == "" || this.length == 0 || ...
- pyqt sender()学习
#!/usr/bin/python # -*- coding: utf-8 -*- # sender.py import sys from PyQt4 import QtGui, QtCore cla ...
- Eclipse上改动Jython代码的Comment颜色
1.问题起因 依据上一篇文章<MonkeyRunner在Windows下的Eclipse开发环境搭建步骤(兼解决网上Jython配置出错的问题)>搭配好Eclipse上面的MonkeyRu ...