This article mainly introduces the PHP header function common HTTP header settings, this article directly gives the code example, the code contains detailed comments, the need for friends can refer to the
?
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 |
//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 '); Tells the browser last modified $time = time () –60; or Filemtime ($FN), etc header (' last-modified: '. Gmdate (' d, D M Y h:i:s ', $time). ' GMT '); Tells the browser that the contents of the document have not changed header (' http/1.1 304 not Modified '); Set the 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 '); Disables the cache header for the 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 the 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 '; |