A simple example of the phpheader () function-php Tutorial

Source: Internet
Author: User
A simple example of the phpheader () function

  1. // Result error
  2. // Output already exists before header () is called
  3. Header ('Location: URL ');
  4. ?>

II. disable browser cache

  1. Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
  2. Header ("Cache-Control: no-cache ");
  3. Header ("Pragma: no-cache ");

3. you are prompted to save a generated PDF file (the Content-Disposition header is used to provide a recommended file name and force the browser to display the save dialog box ):

  1. Header ("Content-type: application/pdf ");

  2. // The file will be called downloaded.pdf

  3. Header ("Content-Disposition: attachment?filename='downloaded= '");

  4. // The PDF source is in original.pdf

  5. Readfile ("original.pdf ");
  6. ?>

4. display a 404 prompt on the visitor's browser.

  1. // 404 not found
  2. Header ("Status: 404 Not Found ");
  3. ?>

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.