& Lt ;? Php/*** Function: PHPheader () examples (PHP) ** Desc: Someexamplesonhowtousetheheader () functionofPHPYoufindadetailedtutorialatexpertsrt.com (English) oratffm. junetz
- /*** Function: PHP header () examples (PHP)
- ** Desc: Some examples on how to use the header () function of PHPYou find a detailed tutorial at expertsrt.com (English) or at ffm.junetz.de (German ). these is also a good help about caching at web-caching.com.
- ** Example: see below.
Tip:You can use these sites to check your headers: web-sniffer.net, html "> delorie.com or www.forret.com.
- ** Author: Jonas John
- */
- // Fix 404 pages:
- Header (HTTP/1.1 200 OK );
- // Set 404 header:
- Header (HTTP/1.1 404 Not Found );
- // Set Moved Permanently header (good for redrictions)
- // Use with location header
- Header (HTTP/1.1 301 Moved Permanently );
- // Redirect to a new location:
- Header (Location: http://www.example.org /);
- // Redrict with delay:
- Header (Refresh: 10; url = http://www.example.org /);
- Print You will be redirected in 10 seconds;
- // You cocould also use the HTML syntax ://
- 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;
- ?>