php的header函数之设置content-type

  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‘;
  1 Content-type 的说明
  2
  3 $mimetypes = array(
  4  ‘ez‘ => ‘application/andrew-inset‘,
  5  ‘hqx‘ => ‘application/mac-binhex40‘,
  6  ‘cpt‘ => ‘application/mac-compactpro‘,
  7  ‘doc‘ => ‘application/msword‘,
  8  ‘bin‘ => ‘application/octet-stream‘,
  9  ‘dms‘ => ‘application/octet-stream‘,
 10  ‘lha‘ => ‘application/octet-stream‘,
 11  ‘lzh‘ => ‘application/octet-stream‘,
 12  ‘exe‘ => ‘application/octet-stream‘,
 13  ‘class‘ => ‘application/octet-stream‘,
 14  ‘so‘ => ‘application/octet-stream‘,
 15  ‘dll‘ => ‘application/octet-stream‘,
 16  ‘oda‘ => ‘application/oda‘,
 17  ‘pdf‘ => ‘application/pdf‘,
 18  ‘ai‘ => ‘application/postscript‘,
 19  ‘eps‘ => ‘application/postscript‘,
 20  ‘ps‘ => ‘application/postscript‘,
 21  ‘smi‘ => ‘application/smil‘,
 22  ‘smil‘ => ‘application/smil‘,
 23
 24  ‘mif‘ => ‘application/vnd.mif‘,
 25  ‘xls‘ => ‘application/vnd.ms-excel‘,
 26  ‘ppt‘ => ‘application/vnd.ms-powerpoint‘,
 27  ‘wbxml‘ => ‘application/vnd.wap.wbxml‘,
 28  ‘wmlc‘ => ‘application/vnd.wap.wmlc‘,
 29  ‘wmlsc‘ => ‘application/vnd.wap.wmlscriptc‘,
 30  ‘bcpio‘ => ‘application/x-bcpio‘,
 31  ‘vcd‘ => ‘application/x-cdlink‘,
 32  ‘pgn‘ => ‘application/x-chess-pgn‘,
 33  ‘cpio‘ => ‘application/x-cpio‘,
 34  ‘csh‘ => ‘application/x-csh‘,
 35
 36 ‘dcr‘ => ‘application/x-director‘,
 37  ‘dir‘ => ‘application/x-director‘,
 38  ‘dxr‘ => ‘application/x-director‘,
 39  ‘dvi‘ => ‘application/x-dvi‘,
 40  ‘spl‘ => ‘application/x-futuresplash‘,
 41  ‘gtar‘ => ‘application/x-gtar‘,
 42  ‘hdf‘ => ‘application/x-hdf‘,
 43  ‘js‘ => ‘application/x-javascript‘,
 44  ‘skp‘ => ‘application/x-koan‘,
 45  ‘skd‘ => ‘application/x-koan‘,
 46  ‘skt‘ => ‘application/x-koan‘,
 47  ‘skm‘ => ‘application/x-koan‘,
 48  ‘latex‘ => ‘application/x-latex‘,
 49  ‘nc‘ => ‘application/x-netcdf‘,
 50  ‘cdf‘ => ‘application/x-netcdf‘,
 51  ‘sh‘ => ‘application/x-sh‘,
 52  ‘shar‘ => ‘application/x-shar‘,
 53  ‘swf‘ => ‘application/x-shockwave-flash‘,
 54  ‘sit‘ => ‘application/x-stuffit‘,
 55  ‘sv4cpio‘ => ‘application/x-sv4cpio‘,
 56  ‘sv4crc‘ => ‘application/x-sv4crc‘,
 57  ‘tar‘ => ‘application/x-tar‘,
 58  ‘tcl‘ => ‘application/x-tcl‘,
 59  ‘tex‘ => ‘application/x-tex‘,
 60  ‘texinfo‘ => ‘application/x-texinfo‘,
 61  ‘texi‘ => ‘application/x-texinfo‘,
 62  ‘t‘ => ‘application/x-troff‘,
 63  ‘tr‘ => ‘application/x-troff‘,
 64  ‘roff‘ => ‘application/x-troff‘,
 65  ‘man‘ => ‘application/x-troff-man‘,
 66  ‘me‘ => ‘application/x-troff-me‘,
 67  ‘ms‘ => ‘application/x-troff-ms‘,
 68  ‘ustar‘ => ‘application/x-ustar‘,
 69  ‘src‘ => ‘application/x-wais-source‘,
 70  ‘xhtml‘ => ‘application/xhtml+xml‘,
 71  ‘xht‘ => ‘application/xhtml+xml‘,
 72  ‘zip‘ => ‘application/zip‘,
 73  ‘au‘ => ‘audio/basic‘,
 74  ‘snd‘ => ‘audio/basic‘,
 75  ‘mid‘ => ‘audio/midi‘,
 76  ‘midi‘ => ‘audio/midi‘,
 77  ‘kar‘ => ‘audio/midi‘,
 78  ‘mpga‘ => ‘audio/mpeg‘,
 79  ‘mp2‘ => ‘audio/mpeg‘,
 80  ‘mp3‘ => ‘audio/mpeg‘,
 81  ‘aif‘ => ‘audio/x-aiff‘,
 82  ‘aiff‘ => ‘audio/x-aiff‘,
 83  ‘aifc‘ => ‘audio/x-aiff‘,
 84  ‘m3u‘ => ‘audio/x-mpegurl‘,
 85  ‘ram‘ => ‘audio/x-pn-realaudio‘,
 86  ‘rm‘ => ‘audio/x-pn-realaudio‘,
 87  ‘rpm‘ => ‘audio/x-pn-realaudio-plugin‘,
 88  ‘ra‘ => ‘audio/x-realaudio‘,
 89  ‘wav‘ => ‘audio/x-wav‘,
 90  ‘pdb‘ => ‘chemical/x-pdb‘,
 91  ‘xyz‘ => ‘chemical/x-xyz‘,
 92  ‘bmp‘ => ‘image/bmp‘,
 93  ‘gif‘ => ‘image/gif‘,
 94  ‘ief‘ => ‘image/ief‘,
 95  ‘jpeg‘ => ‘image/jpeg‘,
 96  ‘jpg‘ => ‘image/jpeg‘,
 97  ‘jpe‘ => ‘image/jpeg‘,
 98  ‘png‘ => ‘image/png‘,
 99  ‘tiff‘ => ‘image/tiff‘,
100  ‘tif‘ => ‘image/tiff‘,
101  ‘djvu‘ => ‘image/vnd.djvu‘,
102  ‘djv‘ => ‘image/vnd.djvu‘,
103  ‘wbmp‘ => ‘image/vnd.wap.wbmp‘,
104  ‘ras‘ => ‘image/x-cmu-raster‘,
105  ‘pnm‘ => ‘image/x-portable-anymap‘,
106  ‘pbm‘ => ‘image/x-portable-bitmap‘,
107  ‘pgm‘ => ‘image/x-portable-graymap‘,
108  ‘ppm‘ => ‘image/x-portable-pixmap‘,
109  ‘rgb‘ => ‘image/x-rgb‘,
110  ‘xbm‘ => ‘image/x-xbitmap‘,
111  ‘xpm‘ => ‘image/x-xpixmap‘,
112  ‘xwd‘ => ‘image/x-xwindowdump‘,
113  ‘igs‘ => ‘model/iges‘,
114  ‘iges‘ => ‘model/iges‘,
115  ‘msh‘ => ‘model/mesh‘,
116  ‘mesh‘ => ‘model/mesh‘,
117  ‘silo‘ => ‘model/mesh‘,
118  ‘wrl‘ => ‘model/vrml‘,
119  ‘vrml‘ => ‘model/vrml‘,
120  ‘css‘ => ‘text/css‘,
121  ‘html‘ => ‘text/html‘,
122  ‘htm‘ => ‘text/html‘,
123  ‘asc‘ => ‘text/plain‘,
124  ‘txt‘ => ‘text/plain‘,
125  ‘rtx‘ => ‘text/richtext‘,
126  ‘rtf‘ => ‘text/rtf‘,
127  ‘sgml‘ => ‘text/sgml‘,
128  ‘sgm‘ => ‘text/sgml‘,
129  ‘tsv‘ => ‘text/tab-separated-values‘,
130  ‘wml‘ => ‘text/vnd.wap.wml‘,
131  ‘wmls‘ => ‘text/vnd.wap.wmlscript‘,
132  ‘etx‘ => ‘text/x-setext‘,
133  ‘xsl‘ => ‘text/xml‘,
134  ‘xml‘ => ‘text/xml‘,
135  ‘mpeg‘ => ‘video/mpeg‘,
136
137 ‘mpg‘ => ‘video/mpeg‘,
138  ‘mpe‘ => ‘video/mpeg‘,
139  ‘qt‘ => ‘video/quicktime‘,
140  ‘mov‘ => ‘video/quicktime‘,
141  ‘mxu‘ => ‘video/vnd.mpegurl‘,
142  ‘avi‘ => ‘video/x-msvideo‘,
143  ‘movie‘ => ‘video/x-sgi-movie‘,
144  ‘ice‘ => ‘x-conference/x-cooltalk‘,
145 );

The following table documents the HTTP MIME types that are available when working with Office 2007 documents:


Ext


MIME Type


.doc


application/msword


.dot


application/msword


.docx


application/vnd.openxmlformats-officedocument.wordprocessingml.document


.dotx


application/vnd.openxmlformats-officedocument.wordprocessingml.template


.docm


application/vnd.ms-word.document.macroEnabled.12


.dotm


application/vnd.ms-word.template.macroEnabled.12


.xls


application/vnd.ms-excel


.xlt


application/vnd.ms-excel


.xla


application/vnd.ms-excel


.xlsx


application/vnd.openxmlformats-officedocument.spreadsheetml.sheet


.xltx


application/vnd.openxmlformats-officedocument.spreadsheetml.template


.xlsm


application/vnd.ms-excel.sheet.macroEnabled.12


.xltm


application/vnd.ms-excel.template.macroEnabled.12


.xlam


application/vnd.ms-excel.addin.macroEnabled.12


.xlsb


application/vnd.ms-excel.sheet.binary.macroEnabled.12


.ppt


application/vnd.ms-powerpoint


.pot


application/vnd.ms-powerpoint


.pps


application/vnd.ms-powerpoint


.ppa


application/vnd.ms-powerpoint


.pptx


application/vnd.openxmlformats-officedocument.presentationml.presentation


.potx


application/vnd.openxmlformats-officedocument.presentationml.template


.ppsx


application/vnd.openxmlformats-officedocument.presentationml.slideshow


.ppam


application/vnd.ms-powerpoint.addin.macroEnabled.12


.pptm


application/vnd.ms-powerpoint.presentation.macroEnabled.12


.potm


application/vnd.ms-powerpoint.presentation.macroEnabled.12


.ppsm


application/vnd.ms-powerpoint.slideshow.macroEnabled.12

时间: 2024-10-10 05:51:56

php的header函数之设置content-type的相关文章

php的header()函数之设置content-type

//定义编码 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'

PHP 使用header函数设置HTTP头的示例方法 表头 (xlsx下载)

转载 http://justcoding.iteye.com/blog/601117/ //定义编码header( 'Content-Type:text/html;charset=utf-8 '); //Atomheader('Content-type: application/atom+xml'); //CSSheader('Content-type: text/css'); //Javascriptheader('Content-type: text/javascript'); //JPEG

the request doesn&#39;t contain a multipart/form-data or multipart/form-data stream, content type header

the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header 一,HTTP上传的基本知识 在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型.下边是说明: application/x-www-form-urlencoded: 窗体数据被编码为名称/值对.这是标准的编码格式. mult

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/

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'

禁用php函数的设置

禁用php函数的设置 打开PHP.INI,找到这行: disable_functions = 在后面那里加上要禁用的函数,如禁用多个函数,要用半角逗号 , 分开 给个例子: disable_functions = passthru,exec,system,popen,chroot,scandir,chgrp,chown,escapesh ellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status 建议在主机上禁用的函数: disable_

header函数使用

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/'); prin

http标头详解/即php中header函数应用解释

HTTP协议header标头详解 分类: Webkit Web Php C/C++ 2012-10-31 11:19 14366人阅读 评论(0) 收藏 举报 本文根据RFC2616(HTTP/1.1规范),参考 http://www.w3.org/Protocols/rfc2068/rfc2068 http://www.w3.org/Protocols/rfc2616/rfc2616 http://www.ietf.org/rfc/rfc3229.txt 通常HTTP消息包括客户机向服务器的请

Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 错误信息: Exception in thread "main" org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or applic