博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PHP header()函数常用方法
阅读量:7072 次
发布时间:2019-06-28

本文共 1341 字,大约阅读时间需要 4 分钟。

PHP header()函数常用方法

定义编码

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

PDF

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.jbxue.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-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 pastheader('Pragma: no-cache');

转载地址:http://ehkml.baihongyu.com/

你可能感兴趣的文章
img 样式单和属性
查看>>
RAID磁盘阵列种类及区别
查看>>
spring MVC自定义视图实现jsonp
查看>>
面向对象之继承时的关键词
查看>>
H3C的CDP——NDP
查看>>
inspect a service on the swarm
查看>>
spark shell的学习
查看>>
安卓模拟器BlueStacks+TCPdump对APP抓包分析
查看>>
maven scope含义的说明
查看>>
Javac编译器源代码分析
查看>>
我的友情链接
查看>>
JAVA中的类型转换 int和String
查看>>
计划任务不能启动
查看>>
网站架构资料收集整理
查看>>
CentOS6.5 Nginx优化编译配置
查看>>
处理异常
查看>>
一个WIndows Server 2008 R2 AD组策略复制排错过程(Warning 13508)
查看>>
SpringBoot之@EnableAutoConfiguration原理及自定义扩展
查看>>
.net CHARTING图表控件下载地址
查看>>
老男孩教育每日一题-第82天-发现文件系统只读了,是什么原因?如何解决?
查看>>