看板 Knuckles_note
作者 標題 [PHP] header 的用法
時間 2015-10-16 Fri. 07:50:08
在PHP使用 header() 可在網頁加上 http header 的參數
使用前不可有任何文字輸出,例如 echo
header("Content-type: text/plain");
可讓瀏覽器將此網頁用純文字輸出這樣就不用再加上<pre></pre>了
header("Content-type: application/json");
讓瀏覽器知道這是 json 格式的網頁header('Location: http://www.example.com/');
可以跳至另一個網頁但header後的執令也會執行,要記得加上 exit;
header("HTTP/1.0 404 Not Found");
產生 HTTP Status Code 網頁header("Cache-Control: no-cache");
讓瀏覽器不暫存此頁面--
※ 作者: Knuckles 時間: 2015-10-16 07:50:08
※ 編輯: Knuckles 時間: 2015-10-19 11:52:05
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 748
2樓 時間: 2016-02-21 10:43:18 (台灣)
→
02-21 10:43 TW
header("refresh:2;url=index.php"); //refresh:[秒數]
回列表(←)
分享