PHP header () function common methods Summary _php tutorial

Source: Internet
Author: User
Defining the Encoding
Copy CodeThe code is as follows: Header (' content-type:text/html;charset=utf-8 ');
Atom
Copy CodeThe code is as follows: Header (' Content-type:application/atom+xml ');
Css
Copy CodeThe code is as follows: Header (' content-type:text/css ');
Javascript
Copy CodeThe code is as follows: Header (' Content-type:text/javascript ');
JPEG Image
Copy CodeThe code is as follows: Header (' content-type:image/jpeg ');
Json
Copy CodeThe code is as follows: Header (' Content-type:application/json ');
Pdf
Copy CodeThe code is as follows: Header (' content-type:application/pdf ');
Rss
Copy CodeThe code is as follows: Header (' content-type:application/rss+xml; charset=iso-8859-1 ');
Text (Plain)
Copy CodeThe code is as follows: Header (' Content-type:text/plain ');
Xml
Copy CodeThe code is as follows: Header (' Content-type:text/xml ');
Ok
Copy CodeThe code is as follows: Header (' http/1.1 OK ');
Set a 404 Header:
Copy CodeThe code is as follows: Header (' http/1.1 404 Not Found ');
Set address to be permanently redirected
Copy CodeThe code is as follows: Header (' http/1.1 301 Moved permanently ');
Go to a new address
Copy CodeThe code is as follows: Header (' location:http://www.example.org/');
File Delay Steering:
Copy CodeThe code is as follows: Header (' refresh:10; url=http://www.example.org/');
print ' You'll be redirected in ten seconds ';
Of course, you can also use HTML syntax to implement
// Copy CodeThe code is as follows: Header (' x-powered-by:php/4.4.0 ');
Header (' x-powered-by:brain/0.6b ');
Document language
Copy CodeThe code is as follows: Header (' content-language:en ');
Tell the browser when it was last modified
Copy CodeThe code is as follows: $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
Copy CodeThe code is as follows: Header (' http/1.1 304 not Modified ');
Set Content length
Copy CodeThe code is as follows: Header (' content-length:1234 ');
Set as a download type
Copy CodeThe code is as follows: 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 for the current document
Copy CodeThe code is as follows: Header (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate ');
Header (' Expires:mon, Jul 1997 05:00:00 GMT '); Date in the past
Header (' Pragma:no-cache ');
To set the content type:
Copy CodeThe code is as follows: 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 files
Header (' Content-type:application/x-shockw**e-flash '); Flash Animation
Show Login dialog box
Copy CodeThe code is as follows: Header (' http/1.1 401 Unauthorized ');
Header (' Www-authenticate:basic realm= ' Top Secret ');
print ' Text that would be displayed if the user hits cancel or ';
print ' enters wrong login data ';

http://www.bkjia.com/PHPjc/752915.html www.bkjia.com true http://www.bkjia.com/PHPjc/752915.html techarticle //Define code copy code as follows: Header (' Content-type:text/html;charset=utf-8 ');//atom copy code code as follows: Header (' Content-type: Application/atom+xml '); CSS Copy ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.