PHP header()的7种用法

   2025-02-22 2520
核心提示:重定向到其他页面:header(Location: http://www.example.com);exit;强制下载文件:header(Content-Disposition: attachment; fi

重定向到其他页面:

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"));

 
 
更多>同类维修知识
推荐图文
推荐维修知识
点击排行
网站首页  |  关于我们  |  联系方式  |  用户协议  |  隐私政策  |  网站留言