溫馨提示×

PHP header()的7種用法

PHP
小云
107
2023-08-28 12:59:13
欄目: 編程語言

  1. 重定向到其他頁面:
header("Location: http://www.example.com");
exit;
  1. 強制下載文件:
header("Content-Disposition: attachment; filename='example.pdf'");
header("Content-Type: application/pdf");
readfile("path/to/example.pdf");
  1. 設置刷新頁面時間:
header("Refresh: 5; url=http://www.example.com");
echo "頁面將在5秒后刷新到新的頁面";
  1. 設置頁面編碼:
header("Content-Type: text/html; charset=UTF-8");
  1. 禁止頁面緩存:
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
  1. 設置頁面狀態碼:
header("HTTP/1.1 404 Not Found");
  1. 設置文件下載大?。?/li>
header("Content-Length: " . filesize("path/to/example.pdf"));

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女