共計 556 個字符,預計需要花費 2 分鐘才能閱讀完成。
PHP 中的 header() 函數(shù)用于發(fā)送 HTTP 標頭。
以下是 header() 函數(shù)的一些常見用法:
- 設(shè)置頁面重定向:
header("Location: http://www.example.com");
exit;
- 設(shè)置頁面字符編碼:
header("Content-Type: text/html; charset=UTF-8");
- 設(shè)置緩存控制:
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
- 設(shè)置文件下載:
header("Content-Disposition: attachment; filename=\"example.txt\"");
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
- 設(shè)置頁面刷新:
header("Refresh: 5; url=http://www.example.com");
這些只是 header() 函數(shù)的一些常見用法,實際上還有許多其他用法。根據(jù)具體需求,你可以使用不同的 HTTP 標頭來控制頁面的行為。
丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!
正文完