欢迎光临
我们一直在努力

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

header(string,replace,http_response_code)

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

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

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

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

跳转:

header(‘location: http://www.codesou.cn/’);发送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做文件下载功能:

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

赞(0) 打赏
未经允许不得转载:码农资源网 » php header()函数详细实用方法
分享到

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册