加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php header()函数详细实用方法

发布时间:2020-12-13 20:53:59 所属栏目:PHP教程 来源:网络整理
导读:header(string,replace,http_response_code) string 必需,规定要发送的报头字符串. replace 可选,指示该报头是否替换之前的报头,或添加第二个报头. 默认是 true(替换),false(允许相同类型的多个报头). http_response_code 可选,把 http 响应代码强制为指定的

header(string,replace,http_response_code)

string 必需,规定要发送的报头字符串.

replace 可选,指示该报头是否替换之前的报头,或添加第二个报头.

默认是 true(替换),false(允许相同类型的多个报头).

http_response_code 可选,把 http 响应代码强制为指定的值,(php 4 以及更高版本可用)

跳转:

header('location: http://www.phpfensi.com/');发送http状态

header("status: 404 not found");

设置缓存:

header("cache-control: no-cache,must-revalidate"); // http/1.1

header("expires:sat,26 jul 1997 05:00:00 gmt");

利用header做文件下载功能:

  1. header("content-type:application/pdf");// 文件将被称为 downloaded.pdf 
  2. header("content-disposition:attachment;filename='downloaded.pdf'");// pdf 源在 original.pdf 中 
  3. readfile("original.pdf"); 

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读