php常見header狀態

2021-09-16 21:09:40 字數 1892 閱讀 6399

<?php  

//200 正常狀態

// 301 永久重定向,記得在後面要加重定向位址 location:$url

// 重定向,其實就是302 暫時重定向

header('location: ');

// 設定頁面304 沒有修改

// 顯示登入框,

header('www-authenticate: basic realm="登入資訊"');

echo '顯示的資訊!';

// 403 禁止訪問

// 404 錯誤

// 500 伺服器錯誤

// 3秒後重定向指定位址(也就是重新整理到新頁面與 相同)

header('refresh: 3; url=');

echo '10後跳轉到';

// 重寫 x-powered-by 值

header('x-powered-by: php/5.3.0');

header('x-powered-by: brain/0.6b');

//設定上下文語言

header('content-language: en');

// 設定頁面最後修改時間(多用於防快取)

$time = time() - 60; //建議使用filetime函式來設定頁面快取時間

header('last-modified: '.gmdate('d, d m y h:i:s', $time).' gmt');

// 設定內容長度

header('content-length: 39344');

header('content-disposition: attachment; filename="example.zip"');

header('content-transfer-encoding: binary');

readfile('example.zip');//讀取檔案到客戶端

//禁用頁面快取

header('cache-control: no-cache, no-store, max-age=0, must-revalidate');

header('expires: mon, 26 jul 1997 05:00:00 gmt');

header('pragma: no-cache');

//設定頁面頭資訊

header('content-type: text/html; charset=iso-8859-1');

header('content-type: text/html; charset=utf-8');

header('content-type: text/plain');

header('content-type: image/jpeg');

header('content-type: audio/mpeg');

//.... 至於content-type 的值 可以去查查 w3c 的文件庫,那裡很豐富

?>

php常用header狀態

200 正常狀態 301 永久重定向,記得在後面要加重定向位址 location url 重定向,其實就是302 暫時重定向 header location 設定頁面304 沒有修改 顯示登入框,header www authenticate basic realm 登入資訊 echo 顯示的資訊!...

PHP中常見的header頭有哪些?

ok 正常訪問header http 1.1 404 not found 通知瀏覽器 頁面不存在 設定位址被永久的重定向 301 跳轉到乙個新的位址 header location 延遲轉向也就是隔幾秒跳轉 header refresh 10 url 內容型別 網頁編碼 header content...

2017 12 18 常見的Header介紹

layout title date author desc in head post 常見header詳解 2017 12 18 22 28 02 0800 南丞 header 函式向客戶端傳送原始的 http 報頭。200 正常狀態 301 永久重定向,記得在後面要加重定向位址 location ...