A detailed description of the PHP header function

Source: Internet
Author: User
The use of this is to set the encoding, send HTTP status values, and redirect.

PHP Header UTF8:

Header ("content-type:text/html; Charset=utf-8″);

PHP header 404:

Header ("http/1.0 404 Not Found");

The above two examples are set UTF8 encoding and sending 404 status.

Header redirection:

Header (' location:http://www.phpthinking.com ');

Other common header usages:

Header permanent redirect, General 301 used with header location. Header (' http/1.1 301 Moved permanently '); header (' location:http:// www.phpthinking.com/')//Header Delay Refresh page//same as the effect in the HTML page
 
   header (' Refresh:10; url=http:// www.phpthinking.com/');//Header Set Page language header (' content-language:en ');//For the download page, you can declare the file type and filename header (' Content-type: Application/octet-stream '), header (' content-disposition:attachment; filename= ' Filename.zip '); Header (' Content-transfer-encoding:binary ')//header set cache and cache expiration Time header (' Cache-control:no-cache, No-store, Max-age=0, Must-revalidate '); header (' Expires:mon, Jul 1997 05:00:00 GMT ');//Header Set page encoding: header (' content-type:text/html; charset=utf-8′);
  • 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.