header(string,replace,http_response_code)
string 必需,規(guī)定要發(fā)送的報頭字符串.
replace 可選,指示該報頭是否替換之前的報頭,或添加第二個報頭.
默認(rèn)是 true(替換),false(允許相同類型的多個報頭).
http_response_code 可選,把 http 響應(yīng)代碼強制為指定的值,(php 4 以及更高版本可用)
跳轉(zhuǎn):
header('location: http://www.companysz.com/');發(fā)送http狀態(tài)
header("status: 404 not found");
設(shè)置緩存:
header("cache-control: no-cache, must-revalidate"); // http/1.1
header("expires:sat,26 jul 1997 05:00:00 gmt");
利用header做文件下載功能:
- header("content-type:application/pdf");// 文件將被稱為 downloaded.pdf
- header("content-disposition:attachment;filename='downloaded.pdf'");// pdf 源在 original.pdf 中
- readfile("original.pdf");
|
新聞熱點
疑難解答