PHP header()的7种用法
- 重定向到其他页面:
header("Location: http://www.example.com");
exit;
- 强制下载文件:
header("Content-Disposition: attachment; filename='example.pdf'");
header("Content-Type: application/pdf");
readfile("path/to/example.pdf");
- 设置刷新页面时间:
header("Refresh: 5; url=http://www.example.com");
echo "页面将在5秒后刷新到新的页面";
- 设置页面编码:
header("Content-Type: text/html; charset=UTF-8");
- 禁止页面缓存:
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
- 设置页面状态码:
header("HTTP/1.1 404 Not Found");
- 设置文件下载大小:
header("Content-Length: " . filesize("path/to/example.pdf"));
版权声明
本文仅代表作者观点,不代表米安网络立场。
上一篇:虚拟主机能绑定多少域名 下一篇:wpf双向绑定怎么实现
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。