(转载)PHP使用header函数设置HTTP头的示例方法表头
代码:
//定义编码
header( 'Content-Type:text/html;charset=utf-8 '); //Atom
header('Content-type: application/atom+xml'); //CSS
header('Content-type: text/css'); //Javascript
header('Content-type: text/javascript'); //JPEG Image
header('Content-type: image/jpeg'); //JSON
header('Content-type: application/json'); //PDF
header('Content-type: application/pdf'); //RSS
header('Content-Type: application/rss+xml; charset=ISO-8859-1'); //Text (Plain)
header('Content-type: text/plain'); //XML
header('Content-type: text/xml'); // ok
header('HTTP/1.1 200 OK'); //设置一个404头:
header('HTTP/1.1 404 Not Found'); //设置地址被永久的重定向
header('HTTP/1.1 301 Moved Permanently'); //转到一个新地址
header('Location: http://www.example.org/'); //文件延迟转向:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds'; //当然,也可以使用html语法实现
// <meta http-equiv="refresh" content="10;http://www.example.org/ /> // override X-Powered-By: PHP:
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b'); //文档语言
header('Content-language: en'); //告诉浏览器最后一次修改时间
$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); //告诉浏览器文档内容没有发生改变
header('HTTP/1.1 304 Not Modified'); //设置内容长度
header('Content-Length: 1234'); //设置为一个下载类型
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile('example.zip'); // 对当前文档禁用缓存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache'); //设置内容类型:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); //纯文本格式
header('Content-Type: image/jpeg'); //JPG***
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音频文件
header('Content-Type: application/x-shockw**e-flash'); //Flash动画 //显示登陆对话框
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';
(转载)PHP使用header函数设置HTTP头的示例方法表头的更多相关文章
- PHP 使用header函数设置HTTP头的示例方法 表头 (xlsx下载)
转载 http://justcoding.iteye.com/blog/601117/ //定义编码header( 'Content-Type:text/html;charset=utf-8 '); ...
- PHP 使用header函数设置HTTP头的示例解析 表头
PHP 使用header函数设置HTTP头的示例解析 表头 //定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header ...
- 非常全面的PHP header函数设置HTTP头的示例
突然看到这个,觉得很好,就拿过来了,如下: //定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Conten ...
- idea如何设置类头注释和方法注释
CSDN 2016博客之星评选结果公布 [系列直播]算法与游戏实战技术 "我的2016"主题征文活动 详细:idea如何设置类头注释和方法注释 标签: idea ...
- intellj idea 如何设置类头注释和方法注释
intellj idea 如何设置类头注释和方法注释 intellj idea的强大之处就不多说了,相信每个用过它的人都会体会到,但是我们也会被他的复杂搞的晕头转向,尤其刚从ecl ...
- PHP header函数设置http报文头(设置头部域)
PHP HTTP 简介: HTTP 函数允许您在其他输出被发送之前,对由 Web 服务器发送到浏览器的信息进行操作. PHP 5 HTTP 函数:header() 向客户端发送原始的 HTTP ...
- PHP header函数设置http报文头示例详解以及解决http返回头中content-length与Transfer-Encoding: chunked的问题
最近在服务器上,多媒体与设备(摄像头)对接的时候,总是发生错误导致设备崩溃,抓包发现响应头不对,没有返回length,使得摄像头立即崩溃.找了一下资料,改了一下响应头就好了. //定义编码 heade ...
- php header()函数设置页面Cache缓存
header()函数在php的使用很大,下面我来介绍利用它实现页面缓存的一些方法,但使用header前必须注意,在它之前不能任何输出,包括空格. 手册上,我们对于cache都是写着如何设置,以便让代码 ...
- PHP header函数设置http报文头示例详解
//定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/at ...
随机推荐
- 关于OS_PRIO_SELF的说明
在看ucosii 中关于删除任务的函数 OSTaskDel 时看到 if (prio == OS_PRIO_SELF) { /* See ...
- Project Euler problem 62
题目的大意很简单 做法的话. 我们就枚举1~10000的数的立方, 然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的. 然后就可以用map来搞了 ...
- [Angular 2] Use Service use Typescript
When creating a service, need to inject the sercive into the bootstrap(): import {bootstrap, Compone ...
- Java模块化概念解惑与现状总结
在过去几年,Java模块化一直是一个活跃的话题.从JSR 277(现已废止)到JSR 291,模块化看起来是Java进化过程中的必经一环.即便是基于JVM的未来语言,比如Scala,也考虑了模块化的问 ...
- 自定义filter包
在有些时候,你可能需要以你的所有项目进行全局的过滤. 因为你的项目可以设计到互相的依赖和调用 . 修改在tomcat下的conf下的web.xml文件.和在原来的web-inif下的修改一样,添加fi ...
- Ubuntu知识记录
1.激活root用户:sudo passwd root 2.安装ftp:apt-get install vsftpd,修改配置文件/etc/vsftpd.conf write_enable=yes表明 ...
- codevs 1047 邮票面值设计
/* 开始没啥好的思路 暴力吧 T的太严重 加了k>n的特判 结果没数据…..然后又暴力生成了几组答案 打表 然而有没有数据 华丽的爆零了 正解 回溯+DP 回溯生成k数组 然后DP找最优解更新 ...
- c# hasvalue属性
// 数据类型? 表示参数的值可以为null空,此时这个参数可调用属性hasvalue来判断,此参数是否有除了null以外的值;进而进行其它的工作 //必须要加?才可用hasvalue属性 priva ...
- ADLINK 8158控制程序-连续运动(VB.NET)
运动平台:日脉的二维运动平台(一个旋转平台和一个滑动平台) 开发环境:VS2010 + .NET Framework + VB.NET 使用文件:pci_8158.vb motion_8158_2D. ...
- winapi获取鼠标位置
using System; using System.Drawing; using System.Runtime.InteropServices; using System.Threading; na ...