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';
下载xlsx文件
- $filename = rtrim($_SERVER['DOCUMENT_ROOT'],'/').'/app/files/payment_status.csv';
- header('Content-Disposition: attachment; filename=payment_status.xlsx');
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Length: ' . filesize($filename));
- header('Content-Transfer-Encoding: binary');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- readfile($filename);
转自:http://blog.csdn.net/kankan231/article/details/37929409
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 '); ...
随机推荐
- PHP框架Yii2.0安装(基础版、高级版)
最近农成也是切入了yiiframework 2.0,就是安装yii2.0就花费了不少的时间,为此做了很多的弯路,特此写一篇博文来给后面学习的同学少走一点的弯路.写的不好的地方欢迎各位学习的同学们能够指 ...
- oracle 常用视图和表
1.查看当前用户的基本信息 select * from user_users 2.查看当前用户的角色 select * from user_role_privs 3.查看当前用户的系统权限和表权限 s ...
- VS中使用系统的环境变量作为INCLUDE和LIBPATH的值
所谓INCLUDE的值实际上就是头文件的搜索路径,而LIBPATH就是.lib的搜索路径,对应着命令行中的/I和/LIBPATH选项 假设你有一个 D:/demo/abc/include/abc.h, ...
- iOS NSUserDefaults的基本使用
/** * NSUserDefaults可以进行轻量级的数据存储 * NSUserDefaults支持的数据类型: NSString, NSNumber, NSDate, NSArray, * NSD ...
- SQL是关于集合的
一 以面向集合的思维方式来思考 公司里每个工作岗位上干了同样年数的员工列表 select emplyee_id from job_history group by employee_id h ...
- define 实例
// ----------------------------------------------define------------------------------------- // #def ...
- Java基础之访问文件与目录——获取与文件存储有关的信息(GetFileStores)
控制台程序,列出存储在系统中的文件的详细信息 import java.nio.file.FileStore; import java.nio.file.FileSystems; import java ...
- jvm内存设置
JVM有很多个内存管理命令,总体而言,分为两类: 1.-X开头的管理命令:这些选项在JDK升级时不会通知修改: 2.-XX开头的管理命令:这些选项不够稳定,所以建议少用. JVM参数的含义: 参数名称 ...
- Struts2配置文件各种标签的含义
最近正在学习Struts2,在配置文件中遇到好多标签,各种意义不同.为了方便学习,便把各种标签的书写和含义总结如下:(随时更新) <struts> <!-- 开启使用开发 ...
- nyist 47 过河问题
http://acm.nyist.net/JudgeOnline/problem.php?pid=47 过河问题 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描述 在漆 ...