1. 程式人生 > >PHP中常見的header頭有哪些?

PHP中常見的header頭有哪些?

// ok 正常訪問header('HTTP/1.1 404 Not Found'); //通知瀏覽器 頁面不存在
header('HTTP/1.1 200 OK'); 
//設定地址被永久的重定向 301
header('HTTP/1.1 301 Moved Permanently');
//跳轉到一個新的地址
header('Location: http://php.itcast.cn/');
//延遲轉向也就是隔幾秒跳轉
header('Refresh:10;url=http://php.itcast.cn/'); 
###內容型別###
//網頁編碼
header('Content-Type: text/html;charset=utf-8'); 
//純文字格式
header('Content-Type:text/plain'); 
//JPG、JPEG
header('Content-Type:image/jpeg');
//ZIP檔案
header('Content-Type:application/zip');
//PDF檔案
header('Content-Type:application/pdf');
//音訊檔案
header('Content-Type: ');
//css檔案
header('Content-type:text/css');

###宣告一個下載的檔案###
header('Content-Type:application/octet-stream');
header('Content-Disposition:attachment;filename="ITblog.zip"');

###顯示一個需要驗證的登陸對話方塊### header('HTTP/1.1 401Unauthorized');
header('WWW-Authenticate:Basic realm="TopSecret"');