在使用php語言開發時,都會見到語言標記,那php語言標記用的是什么呢?有這種“zh_CN”也有“header”。不同的標記內容代表不同信息。所以今天我們來細數一些php相關的語言標記。
200 正常訪問
header('HTTP/1.1 200 OK');
301 設置地址被永久的重定向,進行相應跳轉
header('HTTP/1.1 301 Moved Permanently');
304 告訴瀏覽器文檔內容沒有發生改變
header('HTTP/1.1 304 Not Modified');
403 設置當前頁面禁止訪問
header('HTTP/1.1 403 Forbidden');
404 通知瀏覽器 頁面不存在
header('HTTP/1.1 404 Not Found');
500 服務器錯誤
header('HTTP/1.1 500 Internal Server Error');
網頁重定向
跳轉到一個新的地址,如頭條的網站
header('Location: http://www.toutiao.com/');
延遲轉向 也就是隔幾秒跳轉,也常用于頁面刷新
header('Refresh: 10; url=http://www.toutiao.com/');
修改頭信息
修改 X-Powered-By信息(這個一般是Apache/Nginx等自己相應返回的)
header('X-Powered-By: PHP/8.0.0');
指定文檔語言
header('Content-language: en');
設置內容長度
header('Content-Length: 5566');
通知瀏覽器最后一次修改時間
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
設置此頁面的過期時間(用格林威治時間表示),只要是已經過去的日期即可。
header("Expires: Mon, 12 Jul 2020 01:03:04 GMT");
設置此頁面的最后更新日期(用格林威治時間表示)為當天,可以強制瀏覽器獲取最新內容
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
告訴客戶端瀏覽器不使用緩存,適用于HTTP 1.1 協議
header("Cache-Control: no-cache, must-revalidate");
告訴客戶端瀏覽器不使用緩存,兼容HTTP 1.0 協議
header("Pragma: no-cache");
內容類型
設置網頁編碼
header('Content-Type: text/html; charset=utf-8');
設置純文本格式
header('Content-Type: text/plain');
其他常見內容類型
// jpg jpeg文件 header('Content-Type: image/jpeg'); // zip壓縮文件 header('Content-Type: application/zip'); // PDF文件 header('Content-Type: application/pdf'); // 音頻文件 header('Content-Type: audio/mpeg'); //css文件 header('Content-type: text/css'); //js文件 header('Content-type: text/javascript'); //json header('Content-type: application/json'); //pdf header('Content-type: application/pdf'); //xml格式文件 header('Content-type: text/xml'); //Flash動畫 header('Content-Type: application/x-shockw**e-flash');
聲明一個下載的文件
header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="haoqixin.zip"'); // 這里以haoqixin.zip為演示 header('Content-Transfer-Encoding: binary'); readfile('haoqixin.zip');
對當前文檔禁用緩存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 16 Jul 2021 09:30:00 GMT');
顯示一個需要驗證的登陸對話框
header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="Top Secret"');
聲明一個需要下載的xls文件
header('Content-Disposition: attachment; filename=toutiao.xlsx'); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Length: '.filesize('./haoqixin.xls')); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate'); header('Pragma: public'); readfile('./haoqixin.xls');
總結
好了,“php語言標記用的是什么(php語言標記用的是什么符號)”的相關內容就是以上這些,想要了解更多關于php相關內容歡迎持續關注編程學習網
掃碼二維碼 獲取免費視頻學習資料
- 本文固定鏈接: http://www.wangchenghua.com/post/9052/
- 轉載請注明:轉載必須在正文中標注并保留原文鏈接
- 掃碼: 掃上方二維碼獲取免費視頻資料
查 看2022高級編程視頻教程免費獲取