最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于header的一些常用指令詳解

 更新時(shí)間:2013年06月06日 16:18:19   作者:  
本篇文章是對(duì)header的一些常用指令進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下

header常用指令
header分為三部分:
第一部分為HTTP協(xié)議的版本(HTTP-Version);
第二部分為狀態(tài)代碼(Status);
第三部分為原因短語(Reason-Phrase)。

// fix 404 pages:   用這個(gè)header指令來解決URL重寫產(chǎn)生的404 header
header('HTTP/1.1 200 OK');  

// set 404 header:   頁面沒找到
header('HTTP/1.1 404 Not Found');  

//頁面被永久刪除,可以告訴搜索引擎更新它們的urls
// set Moved Permanently header (good for redrictions)  
// use with location header  
header('HTTP/1.1 301 Moved Permanently'); 

// 訪問受限
header('HTTP/1.1 403 Forbidden');

// 服務(wù)器錯(cuò)誤
header('HTTP/1.1 500 Internal Server Error');

// 重定向到一個(gè)新的位置
// redirect to a new location:  
header('Location: http://www.example.org/');  

延遲一段時(shí)間后重定向
// redrict with delay:  
header('Refresh: 10; url=http://www.example.org/');  
print 'You will be redirected in 10 seconds';  

// 覆蓋 X-Powered-By value
// override X-Powered-By: PHP:  
header('X-Powered-By: PHP/4.4.0');  
header('X-Powered-By: Brain/0.6b');  

// 內(nèi)容語言 (en = English)
// content language (en = English)  
header('Content-language: en');  

//最后修改時(shí)間(在緩存的時(shí)候可以用到)
// last modified (good for caching)  
$time = time() - 60; // or filemtime($fn), etc  
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');  

// 告訴瀏覽器要獲取的內(nèi)容還沒有更新
// header for telling the browser that the content  
// did not get changed  
header('HTTP/1.1 304 Not Modified');  

// 設(shè)置內(nèi)容的長度 (緩存的時(shí)候可以用到):
// set content length (good for caching):  
header('Content-Length: 1234');  

// 用來下載文件:
// Headers for an download:  
header('Content-Type: application/octet-stream');  
header('Content-Disposition: attachment; filename="example.zip"');  
header('Content-Transfer-Encoding: binary');  

// 禁止緩存當(dāng)前文檔:
// load the file to send:readfile('example.zip');  
// Disable caching of the current document:  
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');  
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');  

// 設(shè)置內(nèi)容類型:
// Date in the pastheader('Pragma: no-cache');  
// set content type:  
header('Content-Type: text/html; charset=iso-8859-1');  
header('Content-Type: text/html; charset=utf-8');  
header('Content-Type: text/plain');  

// plain text file  
header('Content-Type: image/jpeg');  

// JPG picture  
header('Content-Type: application/zip');  

// ZIP file  
header('Content-Type: application/pdf');  

// PDF file  
header('Content-Type: audio/mpeg');  

// Audio MPEG (MP3,...) file  
header('Content-Type: application/x-shockwave-flash');  

// 顯示登錄對(duì)話框,可以用來進(jìn)行HTTP認(rèn)證
// Flash animation// show sign in box  
header('HTTP/1.1 401 Unauthorized');  
header('WWW-Authenticate: Basic realm="Top Secret"');  
print 'Text that will be displayed if the user hits cancel or ';  

print 'enters wrong login data';?>

// 發(fā)送一個(gè)200 正常響應(yīng)
header("HTTP/1.1 200 OK");

// 發(fā)送一個(gè)404 找不到資源響應(yīng)
header('HTTP/1.1 404 Not Found');

// 發(fā)送一個(gè)301 永久重定向
header('HTTP/1.1 301 Moved Permanently');

// 發(fā)送一個(gè)503 網(wǎng)站暫時(shí)不能訪問
header('HTTP/1.1 503 Service Temporarily Unavailable');

// 網(wǎng)頁重定向
header('Location: http://m.fzitv.net');

// 設(shè)置網(wǎng)頁3秒后重定向
header('Refresh: 3; url=http://m.fzitv.net');
echo '網(wǎng)頁將在3秒后跳轉(zhuǎn)到http://m.fzitv.net';

// 設(shè)置網(wǎng)頁編碼
header('Content-Type: text/html; charset=utf-8');

// 設(shè)置網(wǎng)頁輸出一個(gè)圖片流
header('Content-Type: image/jpeg');

// 設(shè)置網(wǎng)頁輸出一個(gè)pdf文檔
header('Content-Type: application/pdf');

// 設(shè)置網(wǎng)頁輸出一個(gè)zip文檔
header('Content-Type: application/zip');

相關(guān)文章

最新評(píng)論

稻城县| 民丰县| 平乐县| 铜梁县| 天峻县| 云梦县| 通榆县| 永修县| 栖霞市| 威信县| 陵水| 嘉定区| 新巴尔虎左旗| 仁化县| 新竹县| 博客| 高平市| 大方县| 吉隆县| 曲水县| 启东市| 尚义县| 高密市| 陆良县| 读书| 进贤县| 榆中县| 公安县| 万年县| 安顺市| 马公市| 甘谷县| 常熟市| 吴旗县| 泰来县| 甘南县| 龙门县| 堆龙德庆县| 稻城县| 筠连县| 新田县|