欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

header的一些常用指令介紹-創(chuàng)新互聯(lián)

這篇文章主要介紹“header的一些常用指令介紹”,在日常操作中,相信很多人在header的一些常用指令介紹問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”header的一些常用指令介紹”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

成都創(chuàng)新互聯(lián)公司主營(yíng)進(jìn)賢網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都App制作,進(jìn)賢h5成都小程序開發(fā)搭建,進(jìn)賢網(wǎng)站營(yíng)銷推廣歡迎進(jìn)賢等地區(qū)企業(yè)咨詢

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

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

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

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

//頁(yè)面被永久刪除,可以告訴搜索引擎更新它們的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)容語(yǔ)言 (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)容的長(zhǎng)度 (緩存的時(shí)候可以用到):
// set content length (good for caching):  
header('Content-Length: 1234');  

// 用來(lái)下載文件:
// 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ì)話框,可以用來(lái)進(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)頁(yè)重定向
header('Location: https://www.jb51.net');

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

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

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

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

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

到此,關(guān)于“header的一些常用指令介紹”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

網(wǎng)頁(yè)標(biāo)題:header的一些常用指令介紹-創(chuàng)新互聯(lián)
本文路徑:http://chinadenli.net/article4/cdodoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃移動(dòng)網(wǎng)站建設(shè)品牌網(wǎng)站建設(shè)ChatGPT域名注冊(cè)網(wǎng)站營(yíng)銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)