The header () function of PHP is set Content-type

Source: Internet
Author: User
Tags readfile vars

  1. Defining the Encoding
  2. Header ( ' Content-type:text/html;charset=utf-8 ');
  3. Atom
  4. Header (' Content-type:application/atom+xml ');
  5. Css
  6. Header (' content-type:text/css ');
  7. Javascript
  8. Header (' Content-type:text/javascript ');
  9. JPEG Image
  10. Header (' content-type:image/jpeg ');
  11. Json
  12. Header (' Content-type:application/json ');
  13. Pdf
  14. Header (' content-type:application/pdf ');
  15. Rss
  16. Header (' content-type:application/rss+xml; charset=iso-8859-1 ');
  17. Text (Plain)
  18. Header (' Content-type:text/plain ');
  19. Xml
  20. Header (' Content-type:text/xml ');
  21. Ok
  22. Header (' http/1.1 OK ');
  23. Set a 404 Header:
  24. Header (' http/1.1 404 Not Found ');
  25. Set address to be permanently redirected
  26. Header (' http/1.1 301 Moved permanently ');
  27. Go to a new address
  28. Header (' location:http://www.example.org/');
  29. File Delay Steering:
  30. Header (' refresh:10; url=http://www.example.org/');
  31. print ' You'll be redirected in ten seconds ';
  32. Of course, you can also use HTML syntax to implement
  33. <meta http-equiv= "Refresh" content= "10;http://www.example.org//>
  34. Override x-powered-by:php:
  35. Header (' x-powered-by:php/4.4.0 ');
  36. Header (' x-powered-by:brain/0.6b ');
  37. Document language
  38. Header (' content-language:en ');
  39. Tell the browser when it was last modified
  40. $time = time ()-60; //or Filemtime ($FN), etc
  41. Header (' last-modified: '.  Gmdate (' d, D M Y h:i:s ', $time).'  GMT ');
  42. Tell the browser that the contents of the document have not changed
  43. Header (' http/1.1 304 not Modified ');
  44. Set Content length
  45. Header (' content-length:1234 ');
  46. Set as a download type
  47. Header (' Content-type:application/octet-stream ');
  48. Header (' content-disposition:attachment; filename= ' Example.zip ');
  49. Header (' content-transfer-encoding:binary ');
  50. Load the file to send:
  51. ReadFile (' example.zip ');
  52. Disable caching for the current document
  53. Header (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate ');
  54. Header (' Expires:mon, Jul 1997 05:00:00 GMT '); //Date in the past
  55. Header (' Pragma:no-cache ');
  56. To set the content type:
  57. Header (' content-type:text/html; charset=iso-8859-1 ');
  58. Header (' content-type:text/html; Charset=utf-8 ');
  59. Header (' Content-type:text/plain '); //Plain text format
  60. Header (' content-type:image/jpeg '); //jpg***
  61. Header (' Content-type:application/zip '); //zip file
  62. Header (' content-type:application/pdf '); //pdf file
  63. Header (' content-type:audio/mpeg '); //audio files
  64. Header (' Content-type:application/x-shockw**e-flash '); //flash Animation
  65. Show Login dialog box
  66. Header (' http/1.1 401 Unauthorized ');
  67. Header (' Www-authenticate:basic realm= ' Top Secret ');
  68. Print ' Text that would be displayed if the user hits cancel or ';
  69. Print ' enters wrong login data ';


Download xlsx file

    1. $filename = RTrim ($_server[' document_root '),'/').'  /app/files/payment_status.csv ';
    2. Header (' content-disposition:attachment; filename=payment_status.xlsx ');
    3. Header (' Content-type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ');
    4. Header (' content-length: '.  filesize ($filename));
    5. Header (' content-transfer-encoding:binary ');
    6. Header (' cache-control:must-revalidate ');
    7. Header (' pragma:public ');
    8. ReadFile ($filename);

Transferred from: http://blog.csdn.net/kankan231/article/details/37929409

The header () function of PHP is set Content-type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.