主頁 > 知識庫 > PHP之header函數(shù)詳解

PHP之header函數(shù)詳解

熱門標(biāo)簽:Linux服務(wù)器 電子圍欄 銀行業(yè)務(wù) 服務(wù)器配置 Mysql連接數(shù)設(shè)置 團(tuán)購網(wǎng)站 科大訊飛語音識別系統(tǒng) 阿里云

PHP的header函數(shù)是最常用的函數(shù)之一,用于向客戶端發(fā)送HTTP頭信息。

通過的用法如設(shè)置編碼、發(fā)送HTTP狀態(tài)值以及重定向。

php header utf8 :

header(“Content-type: text/html; charset=utf-8″);

php header 404 :

header(“HTTP/1.0 404 Not Found”);

上述兩個例子分別是設(shè)置UTF8編碼和發(fā)送404狀態(tài)。

header重定向:

header(‘Location: http://www.phpthinking.com');

其他常用的Header用法:

// Header永久性重定向,一般301與header Location一起使用.

header(‘HTTP/1.1 301 Moved Permanently');
header(‘Location: http://www.phpthinking.com/');

// Header延時刷新頁面

//與HTML頁面中的meta http-equiv=”refresh” content=”10;http://www.phpthinking.com” />效果一樣
header(‘Refresh: 10; url=http://www.phpthinking.com/');

// Header設(shè)置頁面語言

header(‘Content-language: en');

// 對于下載頁面,可以聲明文件類型和文件名

header(‘Content-Type: application/octet-stream');
header(‘Content-Disposition: attachment; filename=”filename.zip”‘);
header(‘Content-Transfer-Encoding: binary');

// Header設(shè)置緩存和緩存過期時間

header(‘Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT');

// Header設(shè)置頁面編碼:

header(‘Content-Type: text/html; charset=utf-8′);

到此這篇關(guān)于PHP之header函數(shù)詳解的文章就介紹到這了,更多相關(guān)PHP之header函數(shù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • PHP的命令行擴(kuò)展Readline相關(guān)函數(shù)的使用
  • PHP中垃圾回收相關(guān)函數(shù)的使用
  • PHP中斷言函數(shù)的使用詳解
  • 詳解各種PHP函數(shù)漏洞
  • PHP危險函數(shù)禁用深入詳解
  • PHP的imageTtfText()函數(shù)深入詳解
  • PHP執(zhí)行系統(tǒng)命令函數(shù)實(shí)例講解
  • php中sort函數(shù)排序知識點(diǎn)總結(jié)
  • php中rsort函數(shù)實(shí)例用法
  • 淺談定義一個PHP函數(shù)

標(biāo)簽:大理 棗莊 衡水 江蘇 萍鄉(xiāng) 衢州 廣元 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP之header函數(shù)詳解》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266