<?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头的更多相关文章

  1. Http消息头中常用的请求头和响应头

    作为Web开发对常用http的请求头和响应头熟悉了解一下还是很有必要的.比如请求头中Content-type指定了请求的内容,若类型是application/x-www-form-urlencoded ...

  2. HTTP常用标准请求头字段

    常用标准请求头字段 Accept 设置接受的内容类型 Accept: text/plain Accept-Charset 设置接受的字符编码 Accept-Charset: utf-8 Accept- ...

  3. C++常用的#include头文件总结

    C++常用的#include头文件总结 这篇文章主要介绍了C++常用的#include头文件,对初学者理解C++程序设计大有好处的相关资料   本文详细罗列了C++所包含的头文件的名称及作用说明,比较 ...

  4. php header头信息 举例

    发布:sunday01   来源:Net     [大 中 小] 转自:http://www.jbxue.com/article/6915.html 用于演示PHP header()函数用法的代码,介 ...

  5. curl get请求添加header头信息

    function get($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CU ...

  6. postman5.0.2_0+postmanInterceptor0.2.22_0下载安装,可发送header头 cookie 参数

    Postman是chrome上一个非常好用的http客户端插件,可惜由于chrome安全的限制,发不出带cookie的请求.如果想要发送带cookie的请求,需要开启Interceptor 安装方法: ...

  7. header头参数不能带下划线

    header头参数不能带下划线:game_id是错误的

  8. 数据返回正常 而header头Status=500

    访问接口数据成功返回,但header头Status Code:500,而调用接口的html用ajax访问一直返回500服务器错误,并且ajax一直走error,走不到success中,错误返回状态是连 ...

  9. 提取header头进行模块化处理

    在进行爬取网上东西的时候一般网站都做了UA的过滤,解决办法就是在代码中加入. 所以才有了本篇提取header头信息单独写成一个模块或者说是函数/类的想法,直接上示例 1.把UA头信息在浏览器中复制出来 ...

随机推荐

  1. php的一些小笔记--时间函数

    strtotime  返回UNIX时间戳 .这个函数可以用来计算前天,昨天,后天,明天 例如明天:date('Y-m-d H:is',strtotime('+1 day')) day>1是复数 ...

  2. mongodb3 权限认证问题总结

    mongodb3 权限认证问题总结 标签(空格分隔): mongodb 权限 数据库 认证 ubuntu用户安装最新版本mongodb 添加key sudo apt-key adv --keyserv ...

  3. 排队论的C实现

    大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang 以下鄙人实现了排队论思想,语言是C语言   #include<stdio.h> #in ...

  4. 类XX是公共的,应在名为XX.java的文件中声明public class XX

    找了一个程序粘贴到txt文档中,随便起个名为abc,然后改后缀为.java,接下来在dos中运行时出现以上错误 打开abc.java看了看,声明public class了,但是名字是粘贴过来的类名Wo ...

  5. smarty模板执行原理

    为了实现程序的业务逻辑和内容表现页面的分离从而提高开发速度,php 引入了模板引擎的概念,php 模板引擎里面最流行的可以说是smarty了,smarty因其功能强大而且速度快而被广大php web开 ...

  6. 福建省队集训被虐记——DAY1

    今天算是省冬的第一天--早上柯黑出题,说是"信心欢乐赛",其实是"使你失去信心.不再欢乐的比赛" 顺便orz一下来看这篇文章的各路神犇--求轻虐 水题 (py. ...

  7. Android实现Live Photos 加源代码

    在Android手机上实现类似于iphone中的LivePhoto的功能 源代码分享 github:https://github.com/amazingyyc/DeepRed 代码说明: 1.改变视频 ...

  8. JQuery 选择器 *很重要 多记

    1)基本选择器: 跟CSS选择器类似 2) 层次选择器 div>span   紧接这div同一级下的全部span .one+div     同一等级的div #two~div    同一等级di ...

  9. 用dTree组件生成无限级导航树

     在做管理系统时不可避免要用到导航树,这种东西只要一次做好,就可以随处运行,目前比较好的组件是dTree,原则上可以达到无限级,当然实际运行中4,5级就已经很多了,dTree的速度还是不错的,而且是J ...

  10. Android FragmentActivity onActivityResult冲突问题

    场景:假设fragment的填充数据是ListView,ListView中的每一项都有button,点击每一项的button跳转到B界面.在B界面处理完业务需返回fragment中更新数据. 解决方式 ...