Home >Backend Development >PHP Tutorial >Commonly used header definitions in PHP

Commonly used header definitions in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:42:57778browse
  1. header('HTTP/1.1 200 OK'); // ok normal access
  2. header('HTTP/1.1 404 Not Found'); //Notify the browser that the page does not exist
  3. header(' HTTP/1.1 301 Moved Permanently'); //Set the address to be permanently redirected 301
  4. header('Location: http://www.ithhc.cn/'); //Jump to a new address
  5. header( 'Refresh: 10; url=http://www.ithhc.cn/'); //Delayed redirection means jumping every few seconds
  6. header('X-Powered-By: PHP/6.0.0'); / /Modify X-Powered-By information
  7. header('Content-language: en'); //Document language
  8. header('Content-Length: 1234'); //Set content length
  9. header('Last-Modified: ' .gmdate('D, d M Y H:i:s', $time).' GMT'); //Tell the browser the last modification time
  10. header('HTTP/1.1 304 Not Modified'); //Tell the browser The document content has not changed
  11. ###Content type###
  12. header('Content-Type: text/html; charset=utf-8'); //Web page encoding
  13. header('Content-Type: text/plain '); //Plain text format
  14. header('Content-Type: image/jpeg'); //JPG, JPEG
  15. header('Content-Type: application/zip'); // ZIP file
  16. header('Content -Type: application/pdf'); // PDF file
  17. header('Content-Type: audio/mpeg'); // Audio file
  18. header('Content-type: text/css'); //css file
  19. header('Content-type: text/javascript'); //js file
  20. header('Content-type: application/json'); //json
  21. header('Content-type: application/pdf'); // pdf
  22. header('Content-type: text/xml'); //xml
  23. header('Content-Type: application/x-shockw**e-flash'); //Flash animation
  24. ##### #
  25. ###Declare a downloaded file###
  26. header('Content-Type: application/octet-stream');
  27. header('Content-Disposition: attachment; filename="ITblog.zip"');
  28. header('Content-Transfer-Encoding: binary');
  29. readfile('test.zip');
  30. ######
  31. ###Disable caching for the current document###
  32. header('Cache- Control: no-cache, no-store, max-age=0, must-revalidate');
  33. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  34. ######
  35. ###Display a login dialog box that requires authentication###
  36. header('HTTP/1.1 401 Unauthorized');
  37. header('WWW-Authenticate: Basic realm="Top Secret"');
  38. #### ##
  39. ###Declare an xls file that needs to be downloaded###
  40. header('Content-Disposition: attachment; filename=ithhc.xlsx');
  41. header('Content-Type: application/vnd.openxmlformats- officedocument.spreadsheetml.sheet');
  42. header('Content-Length: '.filesize('./test.xls'));
  43. header('Content-Transfer-Encoding: binary');
  44. header('Cache- Control: must-revalidate');
  45. header('Pragma: public');
  46. readfile('./test.xls');
  47. ######
  48. ?>
Copy code

PHP, header


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP file itselfNext article:PHP file itself