PHP header的几种用法
生活随笔
收集整理的這篇文章主要介紹了
PHP header的几种用法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
-
跳轉(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)容長度
轉(zhuǎn)載于:https://www.cnblogs.com/tudou1223/p/7345140.html
總結(jié)
以上是生活随笔為你收集整理的PHP header的几种用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ASP.NET MVC下的异步Actio
- 下一篇: C++primer 10.2.1节练习