新聞中心
這篇文章主要介紹了PHP中header函數(shù)設(shè)置HTTP頭的示例,具有一定借鑒價(jià)值,需要的朋友可以參考下。希望大家閱讀完這篇文章后大有收獲。下面讓小編帶著大家一起了解一下。
php header函數(shù)設(shè)置HTTP頭的方法:【header( 'Content-Type:text/html;charset=utf-8 ');】,表示設(shè)置編碼為utf-8。
PHP header函數(shù)設(shè)置HTTP頭的示例如下:
定義編碼
header( 'Content-Type:text/html;charset=utf-8 ');
設(shè)置一個(gè)404頭:
header('HTTP/1.1 404 Not Found');
設(shè)置地址被永久的重定向
header('HTTP/1.1 301 Moved Permanently');
轉(zhuǎn)到一個(gè)新地址
header('Location: http://www.example.org/');
文件延遲轉(zhuǎn)向:
header('Refresh: 10; url=http://www.example.org/'); print 'You will be redirected in 10 seconds';
告訴瀏覽器最后一次修改時(shí)間
$time = time() - 60; // or filemtime($fn), etc header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
對(duì)當(dāng)前文檔禁用緩存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Pragma: no-cache');
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享PHP中header函數(shù)設(shè)置HTTP頭的示例內(nèi)容對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,遇到問題就找創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,詳細(xì)的解決方法等著你來學(xué)習(xí)!
網(wǎng)站欄目:PHP中header函數(shù)設(shè)置HTTP頭的示例-創(chuàng)新互聯(lián)
鏈接分享:http://fisionsoft.com.cn/article/cdsigh.html