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');
- //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';
Content-type 的说明 $mimetypes = array(
'ez' => 'application/andrew-inset',
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'bin' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'so' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => 'application/pdf',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil', 'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'bcpio' => 'application/x-bcpio',
'vcd' => 'application/x-cdlink',
'pgn' => 'application/x-chess-pgn',
'cpio' => 'application/x-cpio',
'csh' => 'application/x-csh', 'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'spl' => 'application/x-futuresplash',
'gtar' => 'application/x-gtar',
'hdf' => 'application/x-hdf',
'js' => 'application/x-javascript',
'skp' => 'application/x-koan',
'skd' => 'application/x-koan',
'skt' => 'application/x-koan',
'skm' => 'application/x-koan',
'latex' => 'application/x-latex',
'nc' => 'application/x-netcdf',
'cdf' => 'application/x-netcdf',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'texinfo' => 'application/x-texinfo',
'texi' => 'application/x-texinfo',
't' => 'application/x-troff',
'tr' => 'application/x-troff',
'roff' => 'application/x-troff',
'man' => 'application/x-troff-man',
'me' => 'application/x-troff-me',
'ms' => 'application/x-troff-ms',
'ustar' => 'application/x-ustar',
'src' => 'application/x-wais-source',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => 'application/zip',
'au' => 'audio/basic',
'snd' => 'audio/basic',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'kar' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'm3u' => 'audio/x-mpegurl',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'wav' => 'audio/x-wav',
'pdb' => 'chemical/x-pdb',
'xyz' => 'chemical/x-xyz',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'ief' => 'image/ief',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'png' => 'image/png',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'djvu' => 'image/vnd.djvu',
'djv' => 'image/vnd.djvu',
'wbmp' => 'image/vnd.wap.wbmp',
'ras' => 'image/x-cmu-raster',
'pnm' => 'image/x-portable-anymap',
'pbm' => 'image/x-portable-bitmap',
'pgm' => 'image/x-portable-graymap',
'ppm' => 'image/x-portable-pixmap',
'rgb' => 'image/x-rgb',
'xbm' => 'image/x-xbitmap',
'xpm' => 'image/x-xpixmap',
'xwd' => 'image/x-xwindowdump',
'igs' => 'model/iges',
'iges' => 'model/iges',
'msh' => 'model/mesh',
'mesh' => 'model/mesh',
'silo' => 'model/mesh',
'wrl' => 'model/vrml',
'vrml' => 'model/vrml',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'asc' => 'text/plain',
'txt' => 'text/plain',
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'sgml' => 'text/sgml',
'sgm' => 'text/sgml',
'tsv' => 'text/tab-separated-values',
'wml' => 'text/vnd.wap.wml',
'wmls' => 'text/vnd.wap.wmlscript',
'etx' => 'text/x-setext',
'xsl' => 'text/xml',
'xml' => 'text/xml',
'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'mxu' => 'video/vnd.mpegurl',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'ice' => 'x-conference/x-cooltalk',
);
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 |
php的header函数之设置content-type的更多相关文章
- php的header()函数之设置content-type
//定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header('Content-type: application/at ...
- $_REQUEST变量数组header()函数
$_SERVER 包含http信息头,路径和服务器端的一些信息,没发送一次HTTP请求,就会创建一个$_SERVER数组Array ( [HTTP_HOST] => localhost [HTT ...
- PHP header() 函数详细说明(301、404等错误设置)
原文来自:http://www.veryhuo.com/a/view/41466.html 如果您刚刚开始学习PHP,可能有许多函数需要研究,今天我们就来学习一下PHP Header()的使用方法,更 ...
- the request doesn'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 ...
- PHP 使用header函数设置HTTP头的示例解析 表头
PHP 使用header函数设置HTTP头的示例解析 表头 //定义编码 header( 'Content-Type:text/html;charset=utf-8 '); //Atom header ...
- PHP header函数设置http报文头(设置头部域)
PHP HTTP 简介: HTTP 函数允许您在其他输出被发送之前,对由 Web 服务器发送到浏览器的信息进行操作. PHP 5 HTTP 函数:header() 向客户端发送原始的 HTTP ...
- php header()函数设置页面Cache缓存
header()函数在php的使用很大,下面我来介绍利用它实现页面缓存的一些方法,但使用header前必须注意,在它之前不能任何输出,包括空格. 手册上,我们对于cache都是写着如何设置,以便让代码 ...
- (转载)PHP使用header函数设置HTTP头的示例方法表头
(转载)http://justcoding.iteye.com/blog/601117/ 代码: //定义编码 header( 'Content-Type:text/html;charset=utf- ...
- PHP 使用header函数设置HTTP头的示例方法 表头 (xlsx下载)
转载 http://justcoding.iteye.com/blog/601117/ //定义编码header( 'Content-Type:text/html;charset=utf-8 '); ...
随机推荐
- UVALive - 3026 Period kmp next数组的应用
input n 2<=n<=1000000 长度为n的字符串,只含小写字母 output Test case #cas 长度为i时的最小循环串 循环次数(>1) 若没有则不输出 做法 ...
- power oj/2360/Change
题目链接[https://www.oj.swust.edu.cn/problem/show/2360] 题意:给出两个四位数A.B,目地是用最少的步骤使A变成B.变换规则如下:1.相邻的两位数可以交换 ...
- C# 16位的GUDI
引用: http://www.cnblogs.com/lcwzj/archive/2009/04/16/1436992.html 当我们想要获得一个唯一的key的时候,通常会想到GUID.这个key ...
- cPanel下载及安装信息 /usr/local/cpanel/bin/adduser-->realadduser
cPanel下载及安装信息 2011年03月31日 发布在 编程开发 留下评论 说到cPanel,懂的人都知道玩意得研究研究. ISO安装 http://layer2.cpanel.net/Cen ...
- 如何利用Visual studio 2010创建一个ASP网站?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserLogin.aspx.c ...
- 删除 mysql 日志文件后 ,启动出错
把 mysql-bin.index 里面的索引全部删除
- Docker学习笔记 — Docker私有仓库搭建【转载】
标签: Docker 2015-03-10 21:08 24190人阅读 评论(0) 收藏 举报 分类: Docker(26) 目录(?)[+] 和Mavan的管理一样,Dockers不仅 ...
- VMware设置NAT网络
很多初学者迷茫与如何实现虚拟机VMware与主机互联,这里小编介绍下简单实用的NAT网络. 工具/原料 VMware 方法/步骤 打开VMware,选择 编辑, 虚拟网络编辑器 默认情况下, ...
- VS2008 安装后没有模板
VS2008 安装过程没有任何报错 启动VS2008,新建项目时就成了这样,没有任何模板: 解决方法: 开始 –> 程序 –> Microsoft Visual Studio 2008– ...
- Android OpenGL 入门示例----绘制三角形和正方形
Android上对OpenGl的支持是无缝的,所以才有众多3D效果如此逼真的游戏,在Camera的一些流程中也有用到GLSurfaceView的情况.本文记录OpenGL在Android上的入门级示例 ...