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';

下载xlsx文件

    1. $filename = rtrim($_SERVER['DOCUMENT_ROOT'],'/').'/app/files/payment_status.csv';
    2. header('Content-Disposition: attachment; filename=payment_status.xlsx');
    3. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    4. header('Content-Length: ' . filesize($filename));
    5. header('Content-Transfer-Encoding: binary');
    6. header('Cache-Control: must-revalidate');
    7. header('Pragma: public');
    8. readfile($filename);

最新文章

  1. 【洛谷P2513】逆序对数列
  2. dubbo main方法启动
  3. xcode7 __weak 导致报错 is unavailable
  4. vb6 判断64位操作系统
  5. ViewPager onPageChangeListener总结
  6. JS动画理论
  7. 福州大学 Problem 2169 shadow
  8. wireshark 过滤条件汇总
  9. 重温Javascript(四)-函数
  10. Angular17 Angular自定义指令
  11. JS正则表达式的基础用法
  12. Trusted Execution Technology (TXT) --- 基本原理篇
  13. 搭建SpringMVC+Hibernate
  14. malloc/free与new/delete的区别与联系
  15. c/c++ const this指针
  16. MySQL 误操作后数据恢复(update,delete忘加where条件)【转】
  17. hihocoder 编程练习赛23
  18. python数据结构之图论
  19. python之simplejson,Python版的简单、 快速、 可扩展 JSON 编码器/解码器
  20. flask request模块

热门文章

  1. Python itchat库(1)
  2. RADI
  3. 并发——抽象队列同步器AQS的实现原理
  4. block 的内存结构衍生出来的面试题
  5. awk扩展应用
  6. 好玩Python——PIL项目实训
  7. 使用mpvue开发小程序教程
  8. 微信小程序动态修改页面标题setNavigationBarTitle
  9. How to setup a Alpine Linux mirror
  10. MySQL入门,第三部分,学会添加删除数据库