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'); //200 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报文头示例详解以及解决http返回头中content-length与Transfer-Encoding: chunked的问题
最近在服务器上,多媒体与设备(摄像头)对接的时候,总是发生错误导致设备崩溃,抓包发现响应头不对,没有返回length,使得摄像头立即崩溃.找了一下资料,改了一下响应头就好了. //定义编码 heade ...
- PHP header函数设置http报文头(设置头部域)
PHP HTTP 简介: HTTP 函数允许您在其他输出被发送之前,对由 Web 服务器发送到浏览器的信息进行操作. PHP 5 HTTP 函数:header() 向客户端发送原始的 HTTP ...
- PHP 使用header函数设置HTTP头的示例解析 表头
PHP 使用header函数设置HTTP头的示例解析 表头 //定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header ...
- jni.h头文件详解二
作者:左少华 博客:http://blog.csdn.net/shaohuazuo/article/details/42932813 转载请注明出处:http://blog.csdn.net/shao ...
- 【转】 jni.h头文件详解(二)
原文网址:http://blog.csdn.net/shaohuazuo/article/details/42932813 作者:左少华 博客:http://blog.csdn.net/shaohua ...
- 史上最易懂——ReactNative分组列表SectionList使用详情及示例详解
React Native系列 <逻辑性最强的React Native环境搭建与调试> <ReactNative开发工具有这一篇足矣> <解决React Native un ...
- python中的tcp示例详解
python中的tcp示例详解 目录 TCP简介 TCP介绍 TCP特点 TCP与UDP的不同点 udp通信模型 tcp客户端 tcp服务器 tcp注意点 TCP简介 TCP介绍 TCP协议 ...
- Spring Boot 2.x 快速入门(下)HelloWorld示例详解
上篇 Spring Boot 2.x 快速入门(上)HelloWorld示例 进行了Sprint Boot的快速入门,以实际的示例代码来练手,总比光看书要强很多嘛,最好的就是边看.边写.边记.边展示. ...
- socket编程的同步、异步与阻塞、非阻塞示例详解
socket编程的同步.异步与阻塞.非阻塞示例详解之一 分类: 架构设计与优化 简介图 1. 基本 Linux I/O 模型的简单矩阵 每个 I/O 模型都有自己的使用模式,它们对于特定的应用程序 ...
随机推荐
- 作为从业人员,如果一定要学一门新的编程语言,那么它一定是c++
作为从业人员,如果一定要学一门新的编程语言,那么它一定是c++. 无论各种编程语言排行榜如何变化,什么语言最赚钱,想成为真正的程序员,那么c/c++是必修课,因为几乎所有的底层都是c/c++编写的,各 ...
- HTML JavaScript 基础学习
HTML 中肯定会用到 JavaScript 的知识点,会点 JavaScript 的基础知识不会吃亏,其实打算去买JavaScript的教程去专门学习一下,但是交给我的时间不多了,记录一点,能会一点 ...
- Educational Codeforces Round 21 Problem F (Codeforces 808F) - 最小割 - 二分答案
Digital collectible card games have become very popular recently. So Vova decided to try one of thes ...
- Git基础 —— Github 的使用
Git 基础学习系列 Git 基础 -- 安装 配置 别名 对象 Git 基础 -- 常用命令 Git 基础 -- 常见使用场景 Git基础 -- Github 的使用 Github 的利用 Gith ...
- datagridview控件的使用
http://home.cnblogs.com/group/topic/40730.html datagridview定位到最后一行的方法 this.dataGridView2.CurrentCell ...
- 使用caffe训练自己的图像数据(未完)
参考博客:blog.csdn.net/drrlalala/article/details/47274549 1,首先在网上下载图片,猫和狗.直接保存下载该网页,会生成一个有图片的文件夹.caffe-m ...
- 51nod 1463 找朋友(线段树+离线处理)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1463 题意: 思路: 好题! 先对所有查询进行离线处理,按照右区间排序, ...
- C# 窗口模拟点击按钮或关闭窗口
public class CloseForm { [DllImport("user32", EntryPoint = "FindWindow")] privat ...
- R语言 sub与gsub函数的区别
> text <- c("we are the world", "we are the children") > sub("w&qu ...
- Python matplot的使用(一)
其实,使用它的直接原因是因为matlab太大了,不方便.另外,就是它是免费的. 在安装这个库的时候,会需要安装一些它所依赖的库,比如six等.从sourceforge上下载,只需按照提示安装完成就行了 ...