国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php header函數(shù)的常用http頭設(shè)置

2024-09-04 11:42:35
字體:
供稿:網(wǎng)友

這篇文章主要介紹了php header函數(shù)的常用http頭設(shè)置,本文直接給出代碼實(shí)例,代碼中包含詳細(xì)注釋,需要的朋友可以參考下。

  1. //ok 
  2. header(‘HTTP/1.1 200 OK'); 
  3. //設(shè)置一個(gè)404頭: 
  4. header(‘HTTP/1.1 404 Not Found'); 
  5. //設(shè)置地址被永久的重定向 
  6. header(‘HTTP/1.1 301 Moved Permanently'); 
  7. //轉(zhuǎn)到一個(gè)新地址 
  8. header(‘Location: http://www.example.org/‘); 
  9. //文件延遲轉(zhuǎn)向: 
  10. header(‘Refresh: 10; url=http://www.example.org/‘); 
  11. print ‘You will be redirected in 10 seconds'; 
  12. //當(dāng)然,也可以使用html語法實(shí)現(xiàn) 
  13. // <meta http-equiv=”refresh” content=”10;http://www.example.org/ /> 
  14. // override X-Powered-By: PHP: 
  15. header(‘X-Powered-By: PHP/4.4.0′); 
  16. header(‘X-Powered-By: Brain/0.6b'); 
  17. //文檔語言 
  18. header(‘Content-language: en'); 
  19. //告訴瀏覽器最后一次修改時(shí)間 
  20. $time = time() – 60; // or filemtime($fn), etc 
  21. header(‘Last-Modified: ‘.gmdate(‘D, d M Y H:i:s', $time).' GMT'); 
  22. //告訴瀏覽器文檔內(nèi)容沒有發(fā)生改變 
  23. header(‘HTTP/1.1 304 Not Modified'); 
  24. //設(shè)置內(nèi)容長度 
  25. header(‘Content-Length: 1234′); 
  26. //設(shè)置為一個(gè)下載類型 
  27. header(‘Content-Type: application/octet-stream'); 
  28. header(‘Content-Disposition: attachment; filename=”example.zip”‘); 
  29. header(‘Content-Transfer-Encoding: binary'); 
  30. // load the file to send: 
  31. readfile(‘example.zip'); 
  32. // 對當(dāng)前文檔禁用緩存 
  33. header(‘Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); 
  34. header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past 
  35. header(‘Pragma: no-cache'); 
  36. //設(shè)置內(nèi)容類型: 
  37. header(‘Content-Type: text/html; charset=iso-8859-1′); 
  38. header(‘Content-Type: text/html; charset=utf-8′); 
  39. header(‘Content-Type: text/plain'); //純文本格式 
  40. header(‘Content-Type: image/jpeg'); //JPG*** 
  41. header(‘Content-Type: application/zip'); // ZIP文件 
  42. header(‘Content-Type: application/pdf'); // PDF文件 
  43. header(‘Content-Type: audio/mpeg'); // 音頻文件 
  44. header(‘Content-Type: application/x-shockw**e-flash'); //Flash動畫 
  45. //顯示登陸對話框 
  46. header(‘HTTP/1.1 401 Unauthorized'); 
  47. header(‘WWW-Authenticate: Basic realm=”Top Secret”‘); 
  48. print ‘Text that will be displayed if the user hits cancel or ‘; 
  49. print ‘enters wrong login data';

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 张家口市| 太原市| 句容市| 昌宁县| 黎城县| 思南县| 五寨县| 衡山县| 舞钢市| 青田县| 历史| 张家港市| 苏尼特右旗| 板桥市| 隆子县| 高要市| 黄骅市| 宜良县| 横山县| 广水市| 清涧县| 锡林郭勒盟| 赣榆县| 临西县| 云霄县| 钟山县| 彭阳县| 五台县| 赤城县| 镇平县| 万源市| 吴旗县| 象山县| 湘潭县| 上林县| 伊金霍洛旗| 化州市| 祁连县| 北碚区| 康马县| 康马县|