php的header()函数浅析
来源:互联网 发布:java类依赖 编辑:程序博客网 时间:2024/05/29 04:42
格式:
<?php
header();//为了防止出错header函数请紧跟<?php之后写。
?>
注意事项有以下几点.Location和”:”之间不能有空格,否则会出现错误;在用header前不能有任何的输出(注释:这点大家都知道的,如果header之前有任何的输出,包括空白,就会出现header already sent by xxx的错误);header 后面的东西还会执行的;
1.重定向
header("Location: http://blog.csdn.net");
exit; //在每个重定向之后都必须加上“exit”,避免发生错误后,继续执行。
2.禁止浏览器缓存
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
3.禁止页面在IE中缓存
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' ); //兼容http1.0和https
4.实现文件下载
header('Content-Type: application/octet-stream');//设置内容类型
header('Content-Disposition: attachment; filename="example.zip"'); //设置MIME用户作为附件下载 如果将attachment换成inline意思为在线打开
header('Content-Transfer-Encoding: binary');//设置传输方式
header('Content-Length: '.filesize('example.zip'));//设置内容长度
readfile('example.zip');//读取需要下载的文件
5. 向浏览器发送Status标头
header(”Status: 404 Not Found”);
6ok
header(‘HTTP/1.1 200 OK’);
7设置一个404头
header(‘HTTP/1.1 404 Not Found’);
8设置地址被永久的重定向
header(‘HTTP/1.1 301 Moved Permanently’);
header("Location: http://blog.csdn.net");
- php的header()函数浅析
- php中的header()函数
- php header函数的详细解析(转)
- 关于php的header的函数
- php中header函数的使用
- PHP 中 header()函数的作用
- php header函数的详细解析
- php header函数的详细解析
- PHP header 函数的用法及其注意事项
- 关于PHP header函数跳转的问题
- php中header函数的作用
- PHP header 函数的用法及其注意事项
- php header()函数使用说明
- PHP header() 函数
- PHP header() 函数
- PHP header() 函数
- php header() 函数详解
- PHP函数:header()
- 渐进增强 VS 优雅降级
- 机器学习算法(分类算法)—决策树之ID3算法
- 漫步凸分析六——凸集的相对内点
- MongoDB(六)分片
- c语言常见错误处理方法
- php的header()函数浅析
- 有关文件操作的几个函数
- 唯爱小粽子:mac常用终端开发命令(持续更新中...)
- 循环队列
- 无法启动此程序因为计算机中丢失msvcr110.dll
- 在C语言中,double、long、unsigned、int、char类型数据所占字节数
- java过滤器学习总结
- 练习
- 怎样估算软件项目周期-代码行估算法