一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - PHP教程 - 基于header的一些常用指令詳解

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

2020-04-06 11:41PHP教程網(wǎng) PHP教程

本篇文章是對header的一些常用指令進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下

header常用指令
header分為三部分:

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

// fix 404 pages:   用這個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ù)器錯誤
header('HTTP/1.1 500 Internal Server Error');

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

延遲一段時間后重定向
// 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');  

//最后修改時間(在緩存的時候可以用到)
// 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)容的長度 (緩存的時候可以用到):
// 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');  

// 顯示登錄對話框,可以用來進(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ā)送一個200 正常響應(yīng)
header("HTTP/1.1 200 OK");

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

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

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

// 網(wǎng)頁重定向
header('Location: //m.ythuaji.com.cn');

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

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

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

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

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

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 禁止的爱善良的未删减版hd | 久久精品中文闷骚内射 | 2021国产麻豆剧传媒剧情 | 五月婷婷俺来也 | free性丰满hd性欧美人体 | 大肥臀风间由美 中文字幕 大东北chinesexxxx露脸 | 亚洲成人福利 | 暖暖影院日本版 | 日韩欧美在线观看综合网另类 | 星空无限传媒xk8129 | 201天天爱天天做 | 美女污视频在线观看 | 亚洲 欧美 清纯 校园 另类 | 久久re亚洲在线视频 | 亚洲激情婷婷 | 日本视频在线免费观看 | 亚洲国产成人久久午夜 | 91婷婷射 | 欧美成人在线影院 | 欧美日韩国产亚洲一区二区 | 色先锋av资源中文字幕 | 加勒比一本大道香蕉在线视频 | 国产精品极品美女自在线 | 欧美一区二区三区综合色视频 | 亚洲高清视频在线 | 香蕉久久一区二区不卡无毒影院 | 白丝女仆被啪到深夜漫画 | 天美网站传媒入口网址 | 国产农村乱子伦精品视频 | 全彩调教侵犯h本子全彩妖气he | 男人天堂中文字幕 | 大桥未久aⅴ一区二区 | 亚洲四虎影院 | 五月色婷婷在线影院 | 99久久精彩视频 | 欧美理论片手机在线观看片免费 | 奇米色88欧美一区二区 | 白丝尤物的下面被疯狂蹂躏 | 亚洲欧美成人综合 | 91精品国产综合久久消防器材 | 国产亚洲精品aaa大片 |