RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
PHP函数header发放HTTP头信息

PHP函数header主要可以帮助我们实现向浏览器等user agent 发放http 头信息的函数。下面我们讲为大家详细介绍有关PHP函数header的相关使用方法。#t#

// 向浏览器发送404 状态码
header(“HTTP/1.1 404 Not Found”);
或者
header(“HTTP/1.1 404″);

// 永久重定向
header(“Location: http://weizhifeng.net/”);//默认是301 跳转
// 临时重定向
header(“HTTP/1.1 302 Found”);
header(“Location: http://weizhifeng.net/”);

// 下载文件
header(“Content-type: text/plain’); // 可以替换成你需要的MIME类型
header(‘Content-Disposition: attachment; filename=”weizhifeng.txt”‘);
readfile(‘weizhifeng.txt’);

其他的头信息可以参考HTTP/1.1 specification
如果在header之前已经有了输出,那么请使用ob_start()函数。


文章名称:PHP函数header发放HTTP头信息
当前URL:http://www.jxjierui.cn/article/dheojoh.html