[php] 常用header
来源:互联网 发布:知乎匿名提问 编辑:程序博客网 时间:2024/06/12 06:17
开发常用的header的头
// 重定向跳转
header('Refresh: 10; url=http://www.baidu.com/');
// 301 永久重定向,记得在后面要加重定向地址 Location:$url
header('HTTP/1.1 301 Moved Permanently');
// 成功跳转
header('HTTP/1.1 200 OK');
// 设置一个404头
header('HTTP/1.1 404 Not Found');
// 跳转
header('Location: http://www.baidu.com/');
// 语言设置
header('Content-language: en');
// 告诉浏览器最后一次修改时间
$time = time() - 60; // or filemtime($fn), etcheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// 告诉浏览器文档内容没有发生改变
header('HTTP/1.1 304 Not Modified');
// 下载
header("Content-Type:application/download");
// 强制下载
header("Content-Type:application/force-download");
// 设置头文件类型,可以用于流文件或者文件下载
header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="example.zip"'); header('Content-Transfer-Encoding: binary'); readfile('example.zip'); // 读取文件到客户端
// 附件
header('Content-type: application/pdf'); // 指定内容格式header('Content-Disposition: attachment; filename="downloaded.pdf"'); // 指定内容为附件readfile('original.pdf'); // 打开文件,并输出
// 禁用缓存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// 设置内容长度
header('Content-Length: 39344');
// 设置页面头信息
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'); header('Content-Type: application/zip'); header('Content-Type: application/pdf'); header('Content-Type: audio/mpeg'); header('Content-Type: application/x-shockwave-flash');
// 登录框
header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="登录信息"'); echo '显示的信息!';
// 重写 X-Powered-By 值
header('X-Powered-By: PHP/5.3.0'); header('X-Powered-By: Brain/0.6b');
先写这么多,后期还会继续进行更新!
谢谢关注!
0 0
- [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头部定义汇总
- UVALive - 4452 The Ministers' Major Mess(2-SAT)
- TextView的一些使用
- poj3207Ikki's Story IV - Panda's Trick tarjan缩点
- 零基础学python-1.3 通过idle启动python
- 剑指offer刷题之java实现的栈的压入、弹出序列
- [php] 常用header
- 剩余系,剩余定理,同余定理,费马小定理的证明
- UVa 10815 Andy's First Dictionary
- LeetCode #1 Two Sum
- win7 64位 鼠标右键explorer重启解决方法
- 读书笔记之c和指针(8)
- Linux网络编程(2)——采用TCP的基本server的实现
- 简单记录一下简单的理解
- 【Linux学习】epoll详解