This article mainly introduced PHP header set common file types of Content-type related information, need friends can refer to the following
In PHP, you can send header information through the header function, and you can set the Content-type of the file, following the collation of some common file types for the Content-type value.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5 86 87 88 89 90 91 92 93 |
Date 2015-06-22//Definition Code header (' Content-type:text/html;charset=utf-8 '); //atom header (' Content-type:application/atom+xml '); //CSS header (' content-type:text/css '); //javascript header (' Content-type:text/javascript '); //jpeg Image header (' content-type:image/jpeg '); //json header (' Content-type:application/json '); //pdf header (' content-type:application/pdf '); //rss header (' Content-type:application/rss+xml; charset=iso-8859-1 '); //text (Plain) header (' Content-type:text/plain '); //xml header (' Content-type:text/xml '); //OK header (' http/1.1 ok '); //Set a 404 head: Header (' http/1.1 404 Not Found '); //Set address to be permanently redirected header (' http/1.1 moved Permanently '); //Go to a new address header (' location:http://www.example.org/'); File Delay Steering: Header (' refresh:10 url=http://www.example.org/'); print ' You'll be redirected in seconds '; Of course, you can also use HTML syntax to implement//<meta http-equiv= "Refresh" content= 10;http://www. example.org//> //Override X-powered-by:php:header (' x-powered-by:php/4.4.0 '); Header (' x-powered-by:brain/0.6b '); //Document Language header (' content-language:en '); //Tell browser last modified $time = time ()-60; or Filemtime ($FN), etc header (' last-modified: '. Gmdate (' d, D M Y h:i:s ', $time). ' GMT '); //Tell the browser that the contents of the document have not changed header (' http/1.1 304 not Modified '); //Set Content Length header (' content-length:1234 '); //set to a download type header (' Content-type:application/octet-stream '); Header (' content-disposition:attachment; filename= "Example.zip"); Header (' content-transfer-encoding:binary '); Load the file to Send:readfile (' example.zip '); //Disable cache header for current document (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate '); Header (' Expires:mon, June 1997 05:00:00 GMT '); Date in the past header (' Pragma:no-cache '); //Set Content Type: Header (' content-type:text/html; charset=iso-8859-1 '); Header (' content-type:text/html; Charset=utf-8 '); Header (' Content-type:text/plain '); Plain Text Format header (' Content-type:image/jpeg '); jpg*** header (' Content-type:application/zip '); Zip file header (' Content-type:application/pdf '); PDF file Header (' Content-type:audio/mpeg '); Audio file header (' Content-type:application/x-shockw**e-flash '); Flash animation //Display Login Dialog header (' http/1.1 401 Unauthorized '); Header (' Www-authenticate:basic realm= "top Secret"); print ' Text that'll be displayed if the user hits cancel or '; print ' enters wrong login data '; |
The above is the entire contents of this article, I hope you can enjoy.