亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php header功能的使用

 更新時間:2013年10月28日 15:46:51   作者:  
php header的使用,PHP常見header狀態(tài)總結。

header() 函數向客戶端發(fā)送原始的 HTTP 報頭。

復制代碼 代碼如下:

<?php
//200 正常狀態(tài)
header('HTTP/1.1 200 OK');
// 301 永久重定向,記得在后面要加重定向地址 Location:$url
header('HTTP/1.1 301 Moved Permanently');
// 重定向,其實就是302 暫時重定向
header('Location: http://www.maiyoule.com/');
// 設置頁面304 沒有修改
header('HTTP/1.1 304 Not Modified');
// 顯示登錄框,
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="登錄信息"');
echo '顯示的信息!';
// 403 禁止訪問
header('HTTP/1.1 403 Forbidden');
// 404 錯誤
header('HTTP/1.1 404 Not Found');
// 500 服務器錯誤
header('HTTP/1.1 500 Internal Server Error');
// 3秒后重定向指定地址(也就是刷新到新頁面與 <meta http-equiv="refresh" content="10;http://chabaoo.cn/ /> 相同)
header('Refresh: 3; url=http://chabaoo.cn/');
echo '10后跳轉到http://chabaoo.cn';
// 重寫 X-Powered-By 值
header('X-Powered-By: PHP/5.3.0');
header('X-Powered-By: Brain/0.6b');
//設置上下文語言
header('Content-language: en');
 // 設置頁面最后修改時間(多用于防緩存)
$time = time() - 60; //建議使用filetime函數來設置頁面緩存時間
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// 設置內容長度
header('Content-Length: 39344');
// 設置頭文件類型,可以用于流文件或者文件下載
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
readfile('example.zip');//讀取文件到客戶端

//禁用頁面緩存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Pragma: no-cache');

//設置頁面頭信息
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain');
header('Content-Type: image/jpeg');
header('Content-Type: application/zip');
header('Content-Type: application/pdf');
header('Content-Type: audio/mpeg');
header('Content-Type: application/x-shockwave-flash');
//.... 至于Content-Type 的值 可以去查查 w3c 的文檔庫,那里很豐富
?>

相關文章

最新評論