Using the header function _php tutorial

Source: Internet
Author: User
The header is a string sent by the server to the browser before the HTML data is transmitted to the HTTP, in the header
There is an empty line separating the HTML file. For a detailed description of HTTP, you can refer to RFC 2068 official documents
(http://www.w3.org/Protocols/rfc2068/rfc2068). Before sending the HTML data back to PHP, you should
All headers are passed through.
Note: The traditional header must contain one of the following three headers and can only occur once.
Content-type:xxxx/yyyy
Location:xxxx:yyyy/zzzz
status:nnn xxxxxx
In the new multi-type header specification (Multipart MIME) The party can appear more than two times.
Usage examples
Example one: This example redirects the browser to the official PHP website.
Header ("Location:http://www.php.net");
Exit
?
Example two: Users can get the latest information each time, rather than Proxy or cache data, you can use the following headers
Header ("Expires:mon, Jul 1997 05:00:00 GMT");
Header ("last-modified:".) Gmdate ("D, D M Y h:i:s"). "GMT");
Header ("Cache-control:no-cache, must-revalidate");
Header ("Pragma:no-cache");
?
Example three: Let the user's browser appear unable to find the file information.
Header ("status:404 not Found");
?
Example four: Let the user download the file.
Header ("Content-type:application/x-gzip");

Header ("content-disposition:attachment; Filename= file name ");
Header ("Content-description:php3 Generated Data");
?

http://www.bkjia.com/PHPjc/531887.html www.bkjia.com true http://www.bkjia.com/PHPjc/531887.html techarticle a header is a string that is sent by the server to the HTML file before the HTTP literal to the browser, and a blank line is separated between the header and HTML files. For a detailed description of HTTP, you can ...

  • 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.