In php, the header () function is very useful, especially when ajax is used.
The following is a detailed description of the header.
<? Php P2/** 3 * php header function usage example *: www.jbxue.com * // fix 404 pages: header ('HTTP/1.1 200 404 OK '); // set header: header ('HTTP/1.1 404 Not Found '); // set Moved Permanently header (good for redrictions) // use with location header ('HTTP/1.1 301 Moved Permanently '); // redirect to a new location: header ('location: http://www.jbxue.com /'); // redrict with delay: header ('refresh: 10; url = http :// Www.jbxue.com/'); print 'you will be redirected in 10 seconds'; // You coshould also use the HTML syntax: // <meta http-equiv = "refresh" content = "10; http://www.jbxue.com //> // override X-Powered-By: PHP: header ('x-Powered-: PHP/4.4.0 '); header ('x-Powered-By: Brain/0.6b'); // content language (en = English) header ('content-language: en '); // last modified (good for caching) $ time = time ()-60; // or Filemtime ($ fn), etc header ('Last-Modified :'. gmdate ('d, d m y h: I: s', $ time ). 'gmt'); // header for telling the browser that the content // did not get changed header ('HTTP/1.1 304 Not modified '); // set content length (good for caching): header ('content-Length: 1234 '); // Headers for an download: 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 caching of the current document: header ('cache-Control: no-Cache, no-store, max-age = 0, must-revalidate '); header ('expires: Mon, 26 Jul 1997 05:00:00 gmt'); // Date in the pastheader ('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 file header ('content-Type: image/jpeg '); // JPG picture header ('content-Type: application/zip '); // ZIP file header ('content-Type: application/pdf '); // PDF file header ('content-Type: audio/mpeg '); // Audio MPEG (MP3 ,...) File header ('content-Type: application/x-shockwave-flash'); // flash animation // show sign in box header ('HTTP/1.1 401 unauthorized '); header ('www-Authenticate: Basic realm = "Top Secret" '); print 'text that will be displayed if the user hits cancel or '; print 'enters wrong login data';?>