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');
- 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 转向,php使用header函数的http头设置大全(包含301转向及404状态)
最近做B2B系统,为给每个会员自动赠送的二级域名店铺做一些SEO优化,要用到header函数来设置域名的301转向以及404状态,以下是从网上找的header函数的http头设置大全,收藏到我的博客中 ...
- PHP常用 header函数设置HTTP头部示例
PHP常用 header函数设置HTTP头部示例 定义编码 header( 'Content-Type:text/html;charset=utf-8 '); Atom header('Content ...
- Intellj Idea 如何设置类头注释和方法注释
intellj idea 如何设置类头注释和方法注释 intellj idea的强大之处就不多说了,相信每个用过它的人都会体会到,但是我们也会被他的复杂搞的晕头转向,尤其刚从eclip ...
- idea如何设置类头注释和方法注释
idea和eclipse的注释还是有一些差别的. idea: 类头注释:打开file->setting->Editor->Filr and Code Templates->In ...
- 详细:idea如何设置类头注释和方法注释
idea和eclipse的注释还是有一些差别的. idea: 类头注释:打开file->setting->Editor->Filr and Code Templates->In ...
- 给RabbitMQ发送消息时,设置请求头Header。
消费者的请求头 生产者设置请求头 由于消费者那里,@Payload是接受的消息体,使用了@Header注解,需要请求头,生产者这边就要设置请求头,然后rabbitTemplate再调用convertA ...
- 文件下载响应头 header 属性设置
2019独角兽企业重金招聘Python工程师标准>>> 在服务端处理文件下载时,其实操作起来并不复杂,只有两步就可以完成下载操作. 第一步:设置响应头 const header = ...
- php curl 设置请求头,php的curl请求如何设置header参数
php的curl请求设置header参数的方法:首先使用[CURLOPT_HTTPHEADER]设置HTTP头字段的数组:然后使用一个默认只包含必要的头部字段的HTTP头. php的curl请求设置h ...
- php 无法输出图像,ThinkPHP里无法输出图片 设置响应头
今天写了一个PHP生成图片,想用浏览器查看,但是每次打开都是一串乱码,看样子是图片源二进制数据,然后查看了下响应头是text/html,那我明明设置了image/jpegheader("Co ...
最新文章
- 成功输出消息后的采购订单不能取消审核
- 自监督学习和对比学习
- Boost:顺序一致性的测试程序
- [css] position的relative和absolute定位原点是哪里?
- Shell编程:awk使用总结
- matlab去掉空的元组,python – 删除pandas中包含空元组列表的行
- TensorFlow——Ubuntu系统上TensorFlow的安装教程
- android各版本的sdk区别
- biztalk 2006 产品的版本以及适配器相关信息
- 「转载」微服务分布式架构中,如何实现日志链路跟踪?
- PL / SQL教程
- tomcat xml解析-digester
- HZNUoj 1875 WA Jiana的游戏
- 报名 | 智慧数据云平台与新型城镇化智库论坛
- 123hoo.com网摘中国开发手记(一)都是些简单的东西!:)
- 2011款iMac的AirDrop使用方法。
- 03.豆豆的《背叛》与《天道》
- 史上最烂 spring aop 原理分析
- iTween EaseType 效果
- 破解网页禁用鼠标右键方法
热门文章
- VC ado连接数据库
- 人脸聚类--最好的防御是进攻
- 处理json字符串的问题
- 安装openfst 和 threx的经过
- ftk学习记(combox篇)
- C语言 Linux版俄罗斯方块,C语言版——俄罗斯方块(一)
- 杨洋python_杨洋老师 - 主页
- python修改pdf文件大小,python读pdf文件字体大小_用Python读取pdf文件
- css让子元素展示成一行,封面模板循环子栏目一行两列DIV+CSS成功实现
- js undefined 相等_你知道JS中==和===区别吗?