PHP100 is the first professional website in China to share PHP resources. It also provides a PHP Chinese communication community. For PHP study researchers: The latest PHP information, original content, open source code and PHP video tutorials and other related content. [Introduction] in php, the header () function is very useful, especially when ajax is used. The following is a detailed description of the header.
In php, the header () function is very useful, especially when ajax is used.
The following is a detailed description of the header.
// Override X-Powered-By: PHP: header ('x-Powered-By: PHP/4.4.0 '); header ('x-Powered-: 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 ('H TTP/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 ('cont Ent-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';?>
The above is a detailed description of the PHP header function usage. For more information, see other related articles in the first PHP community!