1. //定义编码
  2. header( 'Content-Type:text/html;charset=utf-8 ');
  3. //Atom
  4. header('Content-type: application/atom+xml');
  5. //CSS
  6. header('Content-type: text/css');
  7. //Javascript
  8. header('Content-type: text/javascript');
  9. //JPEG Image
  10. header('Content-type: image/jpeg');
  11. //JSON
  12. header('Content-type: application/json');
  13. //PDF
  14. header('Content-type: application/pdf');
  15. //RSS
  16. header('Content-Type: application/rss+xml; charset=ISO-8859-1');
  17. //Text (Plain)
  18. header('Content-type: text/plain');
  19. //XML
  20. header('Content-type: text/xml');
  21. // ok
  22. header('HTTP/1.1 200 OK');
  23. //设置一个404头:
  24. header('HTTP/1.1 404 Not Found');
  25. //设置地址被永久的重定向
  26. header('HTTP/1.1 301 Moved Permanently');
  27. //转到一个新地址
  28. header('Location: http://www.example.org/');
  29. //文件延迟转向:
  30. header('Refresh: 10; url=http://www.example.org/');
  31. print 'You will be redirected in 10 seconds';
  32. //当然,也可以使用html语法实现
  33. // <meta http-equiv="refresh" content="10;http://www.example.org/ />
  34. // override X-Powered-By: PHP:
  35. header('X-Powered-By: PHP/4.4.0');
  36. header('X-Powered-By: Brain/0.6b');
  37. //文档语言
  38. header('Content-language: en');
  39. //告诉浏览器最后一次修改时间
  40. $time = time() - 60; // or filemtime($fn), etc
  41. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
  42. //告诉浏览器文档内容没有发生改变
  43. header('HTTP/1.1 304 Not Modified');
  44. //设置内容长度
  45. header('Content-Length: 1234');
  46. //设置为一个下载类型
  47. header('Content-Type: application/octet-stream');
  48. header('Content-Disposition: attachment; filename="example.zip"');
  49. header('Content-Transfer-Encoding: binary');
  50. // load the file to send:
  51. readfile('example.zip');
  52. // 对当前文档禁用缓存
  53. header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
  54. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  55. header('Pragma: no-cache');
  56. //设置内容类型:
  57. header('Content-Type: text/html; charset=iso-8859-1');
  58. header('Content-Type: text/html; charset=utf-8');
  59. header('Content-Type: text/plain'); //纯文本格式
  60. header('Content-Type: image/jpeg'); //JPG***
  61. header('Content-Type: application/zip'); // ZIP文件
  62. header('Content-Type: application/pdf'); // PDF文件
  63. header('Content-Type: audio/mpeg'); // 音频文件
  64. header('Content-Type: application/x-shockw**e-flash'); //Flash动画
  65. //显示登陆对话框
  66. header('HTTP/1.1 401 Unauthorized');
  67. header('WWW-Authenticate: Basic realm="Top Secret"');
  68. print 'Text that will be displayed if the user hits cancel or ';
  69. print 'enters wrong login data';

PHP 使用header函数设置HTTP头的示例方法 表头(转)相关推荐

  1. php header 转向,php使用header函数的http头设置大全(包含301转向及404状态)

    最近做B2B系统,为给每个会员自动赠送的二级域名店铺做一些SEO优化,要用到header函数来设置域名的301转向以及404状态,以下是从网上找的header函数的http头设置大全,收藏到我的博客中 ...

  2. PHP常用 header函数设置HTTP头部示例

    PHP常用 header函数设置HTTP头部示例 定义编码 header( 'Content-Type:text/html;charset=utf-8 '); Atom header('Content ...

  3. Intellj Idea 如何设置类头注释和方法注释

    intellj idea 如何设置类头注释和方法注释         intellj idea的强大之处就不多说了,相信每个用过它的人都会体会到,但是我们也会被他的复杂搞的晕头转向,尤其刚从eclip ...

  4. idea如何设置类头注释和方法注释

    idea和eclipse的注释还是有一些差别的. idea: 类头注释:打开file->setting->Editor->Filr and Code Templates->In ...

  5. 详细:idea如何设置类头注释和方法注释

    idea和eclipse的注释还是有一些差别的. idea: 类头注释:打开file->setting->Editor->Filr and Code Templates->In ...

  6. 给RabbitMQ发送消息时,设置请求头Header。

    消费者的请求头 生产者设置请求头 由于消费者那里,@Payload是接受的消息体,使用了@Header注解,需要请求头,生产者这边就要设置请求头,然后rabbitTemplate再调用convertA ...

  7. 文件下载响应头 header 属性设置

    2019独角兽企业重金招聘Python工程师标准>>> 在服务端处理文件下载时,其实操作起来并不复杂,只有两步就可以完成下载操作. 第一步:设置响应头 const header = ...

  8. php curl 设置请求头,php的curl请求如何设置header参数

    php的curl请求设置header参数的方法:首先使用[CURLOPT_HTTPHEADER]设置HTTP头字段的数组:然后使用一个默认只包含必要的头部字段的HTTP头. php的curl请求设置h ...

  9. php 无法输出图像,ThinkPHP里无法输出图片 设置响应头

    今天写了一个PHP生成图片,想用浏览器查看,但是每次打开都是一串乱码,看样子是图片源二进制数据,然后查看了下响应头是text/html,那我明明设置了image/jpegheader("Co ...

最新文章

  1. 成功输出消息后的采购订单不能取消审核
  2. 自监督学习和对比学习
  3. Boost:顺序一致性的测试程序
  4. [css] position的relative和absolute定位原点是哪里?
  5. Shell编程:awk使用总结
  6. matlab去掉空的元组,python – 删除pandas中包含空元组列表的行
  7. TensorFlow——Ubuntu系统上TensorFlow的安装教程
  8. android各版本的sdk区别
  9. biztalk 2006 产品的版本以及适配器相关信息
  10. 「转载」微服务分布式架构中,如何实现日志链路跟踪?
  11. PL / SQL教程
  12. tomcat xml解析-digester
  13. HZNUoj 1875 WA Jiana的游戏
  14. 报名 | 智慧数据云平台与新型城镇化智库论坛
  15. 123hoo.com网摘中国开发手记(一)都是些简单的东西!:)
  16. 2011款iMac的AirDrop使用方法。
  17. 03.豆豆的《背叛》与《天道》
  18. 史上最烂 spring aop 原理分析
  19. iTween EaseType 效果
  20. 破解网页禁用鼠标右键方法

热门文章

  1. VC ado连接数据库
  2. 人脸聚类--最好的防御是进攻
  3. 处理json字符串的问题
  4. 安装openfst 和 threx的经过
  5. ftk学习记(combox篇)
  6. C语言 Linux版俄罗斯方块,C语言版——俄罗斯方块(一)
  7. 杨洋python_杨洋老师 - 主页
  8. python修改pdf文件大小,python读pdf文件字体大小_用Python读取pdf文件
  9. css让子元素展示成一行,封面模板循环子栏目一行两列DIV+CSS成功实现
  10. js undefined 相等_你知道JS中==和===区别吗?