header函数

2018-10-10  本文已影响0人  一名鼻炎患者

header() 函数向客户端发送原始的 HTTP 报头。

注意:该函数防止一次发送多个报头。这是对头部注入攻击的保护措施。

1.跳转
header('Location: http://www.example.com/');
2.保存

excel文件
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename=test.xlsx');
header('Cache-Control: max-age=0');

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

上一篇下一篇

猜你喜欢

热点阅读