- 跳轉(zhuǎn)頁面
header('Location:'.$url); //Location和":"之間無空格异逐。
- 聲明content-type
header('content-type:text/html;charset=utf-8');
- 返回response狀態(tài)碼
header('HTTP/1.1 404 Not Found');
- 在某個時間后執(zhí)行跳轉(zhuǎn)
header('Refresh: 10; url=http://www.baidu.com/'); //10s后跳轉(zhuǎn)。
- 控制瀏覽器緩存
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
- 執(zhí)行http驗證
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
- 執(zhí)行下載操作
header('Content-Type: application/octet-stream'); //設(shè)置內(nèi)容類型
header('Content-Disposition: attachment; filename="example.zip"'); //設(shè)置MIME用戶作為附件
header('Content-Transfer-Encoding: binary'); //設(shè)置傳輸方式
header('Content-Length: '.filesize('example.zip')); //設(shè)置內(nèi)容長度
Thanks ~